当我在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文件在解决方案的任何地方。


当前回答

对于。net 6,就是这样

dotnet tool update --global dotnet-ef --version 6.0.0

其他回答

忽略这个问题 不要更新你的< 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/

通过dotnet CLI或Package Manager Console或访问更新EF Core工具 这个网站https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Tools/2.1.2 或者你可以忽略这一点。这不是什么大问题……

我的解决方案是从微软https://www.nuget.org/packages/dotnet-ef安装工具dotnet-ef。它使用相同的命令,但没有警告。变化是使用dotnet-ef而不是dotnet ef。

如果你已经安装了。net-ef,那么使用 Dotnet工具更新——global Dotnet -ef——version N.N.N (N.N.N您要更新到的版本)

试试这个: 安装包Microsoft.EntityFrameworkCore.Tools

如果问题仍然存在,则执行以下命令: 更新包Microsoft.EntityFrameworkCore.Tools