如何修复 'Failed to Update dependency information of the project. Please restore the project and try again'

How to fix 'Failed to Update dependency information of the project. Please restore the project and try again'

我正在使用 .net core 2.2 编写一个新网站 API,并且我使用 entity framework 连接了一个现有数据库。但是当我尝试使用 Scaffold new item 将控制器添加到现有模型时,我总是收到上面的错误提示。 这是我使用的命令

Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design

Scaffold-DbContext 用于基于我现有的数据库进行逆向工程和创建 EF 模型。

但一直低于错误

“所选代码生成器出现错误运行:'无法更新项目的依赖信息。请恢复项目并重试。'

我尝试了所有我能想到的方法,甚至在我尝试添加一个空控制器时也遇到了同样的错误

我遇到了这个问题,在我的项目中没有发现任何问题。

删除binobj文件夹后,这个问题就没有了。

这是因为.netCore版本和EntityFrameworkCore版本不匹配。

编辑 我卸载了 EFCore 并为 .net 核心安装了并行版本

例如 .netCore 2.0.9 EFCore 2.2.4

我有同样的错误 然后我卸载了所有软件包并通过 nuget 重新安装它们 我不知道为什么,但它对我有用