c# - 添加迁移显示错误 EntityFrameworkCore.Design 未安装

标签 c# entity-framework visual-studio nuget entity-framework-core

我在这里关注 EntityFrameworkCore 的教程 https://docs.efproject.net/en/staging/platforms/aspnetcore/new-db.html 但是当我到达教程的创建数据库部分时 https://docs.efproject.net/en/staging/platforms/aspnetcore/new-db.html#create-your-database 并运行命令 Add-Migration MyFirstMigration 我收到以下错误:

Cannot execute this command because Microsoft.EntityFrameworkCore.Design is not installed. Install the version of that package that matches the installed version of Microsoft.EntityFrameworkCore and try again.

我尝试安装 Microsoft.EntityFrameworkCore.Design 以及 Microsoft.EntityFrameworkCore.SqlServer.Design NuGet 上的每个版本,但仍然出现相同的错误。

我还尝试使用命令在 NuGet PM 之外运行

  • 网络还原
  • dotnet ef 迁移添加 MyFirstMigration

出现如下错误:

Unhandled Exception: System.MissingMethodException: Entry point not found in assembly 'Microsoft.EntityFrameworkCore.Design, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

我尝试了所有我能想到的方法,并在互联网上到处查找,但仍然没有找到答案。

最佳答案

检查您的 project.json 是否包含这些条目

在依赖下:

"Microsoft.EntityFrameworkCore.Design": {
  "version": "1.0.0-preview2-final",
  "type": "build"
},

"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",

在工具下:

"Microsoft.EntityFrameworkCore.Tools": {
  "version": "1.0.0-preview2-final",
  "imports": [
    "portable-net45+win8+dnxcore50",
    "portable-net45+win8"
  ]
},

关于c# - 添加迁移显示错误 EntityFrameworkCore.Design 未安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40423391/

相关文章:

c# - 数据表行删除问题

c# - 为什么会在运行时陷入困境?

c# - 断言中的逻辑运算符是否可以接受?

c# - NHibernate:仅加载基类对象

c# - 在 EF 4 中,您更喜欢 ObjectSet 还是 CreateQuery?

asp.net-mvc - 如何避免在 Entity Framework 中重复相同的地方

c++ - Visual Studio 反汇编 : losing breakpoints

c - VS2013对C99支持的官方状态是什么?

visual-studio - Visual Studio 2012 的导航按钮如何运作?

c# - TypeDelegator 平等不一致?