c# - 运行所选代码生成器 : 时出错

标签 c# asp.net-core asp.net-core-scaffolding visual-studio-2019

我已经在 Windows 10 上安装了 VS 2019。
创建 ASP.net Core Web 项目 -> 选定的 API。
当我尝试生成引用模型的 Controller 并创建上下文类时,
它没有生成 Controller 类,但它给了我以下错误:

错误,
运行所选代码生成器时出错

'Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.Web.CodeGeneration.Utils, Version=3.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. File name: 'Microsoft.VisualStudio.Web.CodeGeneration.Utils, Version=3.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' at Microsoft.VisualStudio.Web.CodeGeneration.Design.Program.Main(String[] args)

最佳答案

我也有这个问题,但以下答案对我有用。
选择“管理 Nuget 包”并安装这些包

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration" Version="3.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" ExcludeAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Utils" Version="3.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGenerators.Mvc" Version="3.1.2" />

关于c# - 运行所选代码生成器 : 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61442242/

相关文章:

c# - session 结束和重新启动阻止 DropDownList_SelectedIndexChanged 触发

c# - ASP.NET 5 (vNext) 在 Azure 上导致 500 - 内部服务器错误

c# - 使用 ASP.NET MVC,如何最好地避免同时编写添加 View 和编辑 View ?

javascript - 我应该在哪里包含 View 组件的脚本?

.net-core - 指定的 deps.json[] 不存在 - Blazor WebAssembly App 项目类型

.net-core - 查找生成器 'identity' ...给定的程序集名称或代码库无效

c# - 使用 Json.Net 解析 JSON 数组

c# - TransactionScope 抛出异常 "This platform does not support distributed transactions."

c# - 如何指定Entity Framework核心表映射?

c# - Scaffold-DbContext 实例失败 - 从现有数据库创建模型(具有个人身份的项目)