当前位置: 移动技术网 > IT编程>开发语言>.net > EF Core 迁移过程遇到EF Core tools version版本不相符的解决方案

EF Core 迁移过程遇到EF Core tools version版本不相符的解决方案

2018年11月26日  | 移动技术网IT编程  | 我要评论

神龙汽车待遇,等一分钟 歌词,成全善良阅读答案

如果你使用命令:

pm> add-migration inital

提示如下信息时:

the ef core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.4-rtm-31024'

解决方法大致一下几种:

第一


最近在跟着官方的文档学习 .net core 。 在写 “创建 razor 页面 web 应用” demo 中的——“添加模型”这一篇的教程,“添加初始迁移”中遇到 “the ef core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.3-rtm-32065'. update the tools for the latest features and bug fixes.”这样的问题。

这个问题是用 pmc 命令做“初始迁移”的时候出现的,找了很多方法都不行,也看了本机安装的 .net core 的版本(dotnet --version,dotnet --info)。

最后解决办法: 项目文件夹下使用 .net core cli 命令: dotnet ef migrations add initial dotnet ef database update 完成后运行可以了

第二


编辑你的<项目名称>.csproj文件

添加以下内容

<project sdk="microsoft.net.sdk.web">

  <propertygroup>
    <targetframework>netcoreapp2.1</targetframework>
  </propertygroup>

  <itemgroup>
    <packagereference include="microsoft.aspnetcore.app" />
    <packagereference include="microsoft.entityframeworkcore.tools" version="2.1.4" />
    <packagereference include="microsoft.aspnetcore.razor.design" version="2.1.2" privateassets="all" />
    <packagereference include="microsoft.visualstudio.web.codegeneration.design" version="2.1.6" />
  </itemgroup>

</project>

然后运行命令:

pm> update-package

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网