dotnet-ef 添加迁移,失败

dotnet-ef 添加迁移,失败

我尝试将 Entity Framework 添加到我正在构建的应用程序中。一切正常。在我添加 Entity Framework 迁移之前,应用程序已编译并启动,但当我尝试添加迁移时,我收到了此错误消息。

Debug/net8.0$ dotnet dotnet-ef migrations add InitialCreate
Cannot execute because the specified command or file is not found.
Possible reasons for this are as follows:
  * The dotnet built-in command was written incorrectly.
  * A .NET program was intended to execute, but dotnet-dotnet-ef does not exist.
  * A global tool was intended to be executed, but an executable file with the dotnet prefix of that name cannot be found in the PATH path.
Debug/net8.0$ ~/.dotnet/tools/dotnet-ef migrations add InitialCreate
You must install .NET to run this application.

App: /home/kamil/.dotnet/tools/dotnet-ef  
Architecture: x64  
App host version: 8.0.2  
.NET location: Not found  

Learn more:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=linux-x64&os=ubuntu.22.04&apphost_version=8.0.2

但是当我输入:dotnet --info我得到了这个结果:

.NET SDK:
 Version:           8.0.200
 Commit:            438cab6a9d
 Workload version:  8.0.200-manifests.cdf2cc8e

Launch environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /snap/dotnet-sdk/236/sdk/8.0.200/

Installed .NET platform workloads:
No installed workloads to display.

Host:
  Version:      8.0.2
  Architecture: x64
  Commit:       1381d5ebd2
.NET SDKs installed:
  8.0.200 [/snap/dotnet-sdk/236/sdk]
.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.2 [/snap/dotnet-sdk/236/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.2 [/snap/dotnet-sdk/236/shared/Microsoft.NETCore.App]
Other architectures found:
  None
Environment variables:
  Not set
global.json file:
  Not found
Learn more:
  https://aka.ms/dotnet/info
Download .NET:
  https://aka.ms/dotnet/download
;

echo $DOTNET_ROOT
result:
/snap/dotnet-sdk/236/sdk

我还全局安装了 dotnet-ef

 dotnet tool install --global dotnet-ef

这是怎么回事?

相关内容