EFCore-脚手架Scaffold发生Build Failed问题的终极解决

大家在使用EntityFrameworkCore的DBFirst的脚手架(Scaffolding)时应该遇到过Build Failed的错误,而没有任何提示,我也遇到过不少次,目前已经完美解决并将排查方法分享给大家:

(1)对于要使用脚手架的项目,首先要确保项目是可以正常编译运行的,在VisualStudio中Ctrl+Shift+B进行编译,如果报错,则要先处理好。

(2)确保引用的EntityFrameWork相关包完整、正确,以下是我使用的版本:

  Microsoft.EntityFrameworkCore.Design(2.1.8)

  Microsoft.EntityFrameworkCore.Tools(2.1.8)

  Microsoft.EntityFrameworkCore.SqlServer(2.1.8)

(3)开启脚手架命令行运行的错误提示,以便我们查找问题:

  dotnet ef dbcontext scaffold "连接字符串" Microsoft.EntityFrameworkCore.SqlServer -o Model -c DefaultContext -f -v

命令最后的-v就是打开错误提示,命令行运行时如果发现错误则会提示

(4)我遇到的错误原因:

  1、项目之间相互依赖导致的问题,可以试试取消相互之间的引用再运行

2、提示“C# 7.0 中不支持功能“默认文本”。请使用 7.1 或更高的语言版本。”,可能是因为你的解决方案里出现了不同版本的.Net(比如.NetStandard和.NetFramework共同出现在同一个解决方案下)。这时只需要在项目文件中增加配置项即可解决:
  <PropertyGroup>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>

或者在“项目属性 > 生成 > 高级 > 语言版本”中设置即可

原文地址:https://www.cnblogs.com/cdoneiX/p/12236970.html

时间: 2024-08-08 12:24:06

EFCore-脚手架Scaffold发生Build Failed问题的终极解决的相关文章

Android Studio 中 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task &#39;:compileDebugAidl&#39;.的问题解答

Android Studio 中 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileDebugAidl'.的问题解答 完整的问题提示 Gradle: FAILURE:Build failed with an exception.*What went wrong:Execution failed for task ':compileDebugAidl'.>No

BUILD FAILED D:\build.xml:2: 前言中不允许有内容。

1.错误描述 Microsoft Windows [版本 6.1.7601] 版权所有 (c) 2009 Microsoft Corporation.保留所有权利. C:\Users\Administrator>d: D:\>ant Buildfile: D:\build.xml BUILD FAILED D:\build.xml:2: 前言中不允许有内容. Total time: 0 seconds D:\> 2.错误原因 3.解决办法

cocos2d-x 3.6运行cocos run出现Ndk build failed解决办法

我运行cocos run -p android编译成安卓APK的时候提示:jni/../../Classes/AppDelegate.cpp:67: error: undefined reference to 'GameMain::c reateScene()', 最后出现错误提示:Ndk build failed!,其中GameMain是我自己写的代码,. 后来找到了原因,有两种解决办法: 第一种方法:在\proj.android\jni下面的Android.mk的文件里面,在LOCAL_SR

Page build failed: Missing submodule的解决方案

最近想整理一下工作室官网的东西,那是一个用github pages写的网站,在上传一些post文章的时候,突然给我发邮件说有错误: The page build failed with the following error: The submodule `52FeidianStudio.github.io` was not properly initialized with a `.gitmodules` file. For more information, see https://help

Android Studio升级后工程Build failed.

最近在升级Android Studio后,发现原先能编译通过的工程,突然就编译不过了,原因是生成的AndroidManifest.xml文件中有乱码. 升级后: android studio 0.6.0 build tools 19.1.0 Android SDK tools 22.6.4. gradle 0.11.+ 错误信息: Error Info Error:(11) Error parsing XML: not well-formed (invalid token) Error:(11)

FAILURE: Build failed with an exception. Crunching Cruncher screen.png failed

自己测试ionic的模板项目cutePuppyPics时,按照https://github.com/driftyco/ionic/blob/2.0/CHANGELOG.md#angular-update-to-200-rc1  升级Angularjs版本后,运行cordova build android 编译项目时总是报如下错 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task

BUILD FAILED D:\build.xml:2: 前言中不同意有内容。

1.错误描写叙述 Microsoft Windows [版本号 6.1.7601] 版权全部 (c) 2009 Microsoft Corporation. 保留全部权利. C:\Users\Administrator>d: D:\>ant Buildfile: D:\build.xml BUILD FAILED D:\build.xml:2: 前言中不同意有内容. Total time: 0 seconds D:\> 2.错误原因 3.解决的方法

vue.js报错:Module build failed: Error: No parser and no file path given, couldn&#39;t infer a parser.

ERROR Failed to compile with 2 errors 12:00:33 error in ./src/App.vue Module build failed: Error: No parser and no file path given, couldn't infer a parser. at normalize (C:\Users\admin\Desktop\222\demo\node_modules\prettier\index.js:7051:13) at form

【Vue报错】Module build failed: Error: No parser and no file path given, couldn&#39;t infer a p arser.

在创建一个vue项目启动时报错,报错的内容为: error in ./src/App.vue Module build failed: Error: No parser and no file path given, couldn't infer a p arser. at UndefinedParserError.Wrapper (D:\dyyc\bookstore\[email protected] [email protected]\index.js:1948:14) at new Und