加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – Add-Migration显示错误EntityFrameworkCore.Design未安装

发布时间:2020-12-15 08:14:07 所属栏目:百科 来源:网络整理
导读:我在这里关注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 并
我在这里关注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恢复
> 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"
  ]
},

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读