如何修复 dotnet ef 工具,找不到 .NET 位置

Apr*_*tio 14 ubuntu entity-framework-core .net-core asp.net-core

我使用实体框架核心创建了一个 .net core 7 项目。嗯,当时我安装了.net core 6,所以我的全局ef工具还是版本6,然后我更新到版本7。这里我遇到了问题,它说我没有安装框架。我决定卸载 dotnet。然后我重新安装了sdk 7和全局ef工具。并出现新的错误。我尝试重新安装很多次。但还是这样,现在ef工具用不了了。

This is dotnet --info

    .NET SDK:
 Version:   7.0.101
 Commit:    bb24aafa11

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /usr/share/dotnet/sdk/7.0.101/

Host:
  Version:      7.0.1
  Architecture: x64
  Commit:       97203d38ba

.NET SDKs installed:
  7.0.101 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/usr/lib/dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
Run Code Online (Sandbox Code Playgroud)

这就是错误,

You must install .NET to run this application.

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

Learn about runtime installation:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=ubuntu.22.04-x64&apphost_version=7.0.1
Run Code Online (Sandbox Code Playgroud)

Apr*_*tio 26

我找到了答案;/usr/share/dotnet我更改了dotnet 7中的根 dotnet env 。

export `DOTNET_ROOT=/usr/share/dotnet`
Run Code Online (Sandbox Code Playgroud)

  • 谢谢,@B3zaleel 例如,它看起来像[安装程序](https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install) 将其放在`$HOME/ .dotnet` 对我来说 (2认同)