*你打算执行 .NET Core 程序,但 dotnet-ef 不存在。

.NET做数据迁移安装dotnet -ef命令工具

可能的原因包括:
  *你拼错了内置的 dotnet 命令。
  *你打算执行 .NET Core 程序,但 dotnet-ef 不存在。
  *你打算运行全局工具,但在路径上找不到名称前缀为 dotnet 的可执行文件。

.net core3.0 以上版本dotnet ef命令不在是sdk的一部分,需要单独安装,使用如下命令:(最新版)

dotnet tool install --global dotnet-ef

该命令默认安装的是最新版本,如果项目中使用的并不是最新版本,则还是不能使用,安装对应版本使用如下命令:(指定版本)

dotnet tool install --global dotnet-ef --version 3.1.1

不注意安装错误可使用卸载命令:

dotnet tool uninstall --global dotnet-ef

dotnet-ef安装成功后,还需要给项目引用nuget包:

dotnet add package Microsoft.EntityFrameworkCore.Design

操作失败的话检查一下版本号即可

原文地址:https://www.cnblogs.com/GarsonZhang/p/13916428.html