当我在VS 2017包管理器控制台中使用dotnet ef工具时,我得到了一个需要更新ef核心工具的警告消息:
PM> dotnet ef migrations list -s ../RideMonitorSite
The EF Core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.2-rtm-30932'. Update the tools for the latest features and bug fixes.
20180831043252_Initial
但是我的csproj文件有这样的条目:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.2" />
</ItemGroup>
我已经确认安装的版本实际上已经过时了:
PM> dotnet ef --version
Entity Framework Core .NET Command-line Tools
2.1.1-rtm-30846
那么我该怎么更新工具呢?顺便说一句,我在其他答案中看到过一个过时的全局。Json文件会导致这个问题。但是我没有全局。Json文件在解决方案的任何地方。
忽略这个问题
不要更新你的< PackageReference Include = "微软。EntityFrameworkCore。Tools " Version ="" / > .
在我的情况下,我向前移动与'Update-Database -Context MyElementContext',现在它都工作得很好。
我是在《编程ASP》这本书里找到的。迪诺·埃斯波西托的NET Core。
'Note This version of the CLI tooling is not the same as the version of the .NET Core runtime the application will use. The runtime version is specified in the project file, and you can comfortably edit it from within the user interface of the IDE of your choice. If you want, instead, to edit the project file manually, then it is as easy as editing the .csproj XML fi le and changing the value of the TargetFramework element. The value refers to the moniker that identifies the version (such as netcoreapp2.0).'
对我有效的解决方案是在包管理器控制台中运行以下命令:
PM> Install-Package Microsoft.EntityFrameworkCore -Version 2.1.11
PM> Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.1.11
确保版本与错误消息中的版本匹配,在我的情况下,我得到了以下错误:
The EF Core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.11-servicing-32099'. Update the tools for the latest features and bug fixes.
查看以下站点的可用版本:
https://www.nuget.org/packages/Microsoft.EntityFrameworkCore/