升级到 Visual Studio 16.3.0 后,dotnet ef 命令不再有效

dotnet ef command no longer works after upgrading to Visual Studio 16.3.0

这首先发生在家里,所以我认为这可能是我家里台式电脑的问题。但是现在我回来工作了,我尝试升级并得到了同样的东西。

升级前的截图

升级后的截图Visual Studio

我得到的错误是:

Could not execute because the specified command or file was not found.

Possible reasons for this include:

  • You misspelled a built-in dotnet command.
  • You intended to execute a .NET Core program, but dotnet-ef does not exist.
  • You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

关于为什么会发生这种情况有什么想法吗?以及如何取回 dotnet ef 命令。我的意思是之前必须在 $PATH 中,否则它不会在之前工作。

这是一个breaking change in Entity Framework Core 3.0:

The EF Core command-line tool, dotnet ef, is no longer part of the .NET Core SDK.

...

Starting in 3.0, the .NET SDK does not include the dotnet ef tool, so before you can use it you have to explicitly install it as a local or global tool.

您需要安装 Entity Framework Core Tools。要全局安装它,运行 在命令行上这样做:

dotnet tool install --global dotnet-ef