需要更新EF核心工具

Mar*_*ert 32 entity-framework-core

当我在VS 2017包管理器控制台中使用dotnet ef工具时,我收到有关需要更新EF Core工具的警告消息:

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
Run Code Online (Sandbox Code Playgroud)

但是我的csproj文件有这个条目:

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.2" />
  </ItemGroup>
Run Code Online (Sandbox Code Playgroud)

我已经确认安装的版本实际上是过时的:

PM> dotnet ef --version
Entity Framework Core .NET Command-line Tools
2.1.1-rtm-30846
Run Code Online (Sandbox Code Playgroud)

那么我该如何更新工具呢?顺便说一下,我在其他答案中看到过时的global.json文件会导致这个问题.但我在解决方案的任何地方都没有global.json文件.

Mar*_*tin 426

针对特定版本使用命令行、CmdPowerShell

dotnet tool update --global dotnet-ef --version 3.1.0

或用于最新版本(也适用于重新安装)

dotnet tool update --global dotnet-ef

  • 为什么他们不能把这个 **IN** 错误消息! (111认同)
  • 哎呀,我创建了一个 PR:https://github.com/dotnet/efcore/pull/20792 (18认同)
  • 就我而言,更新到最新版本不起作用。但从错误消息中我可以得到我必须从 3.1.6 更新到 **5.0.2** 的信息,所以我使用了特定的更新`dotnet tool update --global dotnet-ef --version 5.0.2`你建议了,而且成功了。谢谢!;-) (4认同)
  • 我的版本是 3.0.0,第一个命令对我有用,但第二个命令没有。当运行不指定任何版本的命令时,我收到以下错误:工具“dotnet-ef”由于以下原因无法更新:无法恢复工具包... (2认同)
  • 有一天我们也许应该做一个公关......@Simon_Weaver (2认同)

uno*_*aii 27

对于.NET 6,这将是

dotnet tool update --global dotnet-ef --version 6.0.0
Run Code Online (Sandbox Code Playgroud)

  • 为什么要在命令中添加版本号?只需运行: dotnet tool update --global dotnet-ef 即可。 (2认同)

Mar*_*ert 18

在github上将这个问题反馈给了开发团队.事实证明,这是当前工具或nuget包中的一个已知问题,当您创建基于EF Core的AspNet Core站点时会加载这些包.它的目标是在未来版本中修复.

目前,解决方法只是忽略警告.

还提供了另一种解决方法,包括调整csproj文件以明确定义AspNet Core元数据包的版本 - 当我写这篇文章时它达到2.1.3 - 但我无法使用该方法; 我仍然收到警告信息.


Pat*_*tee 7

对我有用的解决方案在程序包管理器控制台中运行以下命令:

PM> Install-Package Microsoft.EntityFrameworkCore -Version 2.1.11
PM> Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.1.11
Run Code Online (Sandbox Code Playgroud)

如果我遇到以下错误,请确保版本与错误消息中的版本匹配:

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.
Run Code Online (Sandbox Code Playgroud)

检查可从以下站点获得的版本:https : //www.nuget.org/packages/Microsoft.EntityFrameworkCore/


Lem*_*raj 6

试试这个: Install-Package Microsoft.EntityFrameworkCore.Tools

如果仍然出现问题,请同时执行以下操作: Update-Package Microsoft.EntityFrameworkCore.Tools

  • 这是一个很好的建议,但是并没有为我解决_problem_问题。 (2认同)

joa*_*mja 5

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

如果您已经安装了 dotnet-ef,则使用 dotnet tool update --global dotnet-ef --version n.n.n(nnn 您要更新的版本)