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


当前回答

我的解决方案是从微软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您要更新到的版本)

其他回答

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

我在github上把这个问题转给了开发团队。事实证明,这是一个已知的问题,在当前的工具或nuget包中,当你创建一个EF Core驱动的AspNet Core站点时加载。这个问题将在未来的版本中修复。

目前,解决方法是忽略该警告。

还提供了另一种解决方案,包括调整csproj文件来明确定义AspNet核心元包的版本——当我写这篇文章时,它已经达到2.1.3了——但我无法让这种方法工作;我还是不断收到警告信息。

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

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

对于。net 6,就是这样

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

我的解决方案是从微软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您要更新到的版本)