EF Core工具无法正确安装

huangapple go评论62阅读模式
英文:

EF Core tools won't install properly

问题

I can't seem to use dotnet ef core tools...
我似乎无法使用dotnet ef核心工具...

I somehow created the database on this project some time ago. I just tried to update it after some DB changes with:
不知何故,我在一段时间前在此项目上创建了数据库。我刚尝试在一些数据库更改后进行更新:

dotnet ef database update --connection "[connection string]"

but I get:
但我收到以下错误:

Could not execute because the specified command or file was not found.
由于找不到指定的命令或文件,无法执行。
Possible reasons for this include:
可能的原因包括:

  • You misspelled a built-in dotnet command.
  • 您拼写错误了内置的dotnet命令。
  • You intended to execute a .NET program, but dotnet-ef does not exist.
  • 您打算执行一个.NET程序,但dotnet-ef不存在。
  • You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
  • 您打算运行一个全局工具,但是在PATH上找不到以dotnet为前缀的具有此名称的可执行文件。

So I tried:
因此,我尝试了以下操作:

dotnet tool install --global dotnet-ef

But it told me the tools were already installed. So I uninstalled, then reinstalled, both of which said they were successful. And for good measure I did:
但它告诉我工具已经安装。所以我卸载了它,然后重新安装,两者都显示安装成功。并为了保险起见,我还进行了以下操作:

dotnet tool update --global dotnet-ef

which responded with:
响应如下:

Tool 'dotnet-ef' was reinstalled with the latest stable version (version '7.0.5').
工具'dotnet-ef'已重新安装为最新的稳定版本(版本'7.0.5')。

But the command still doesn't work and
但命令仍然无法工作,而且

dotnet tool list

shows nothing.
什么也没有显示。

How can I fix this?
我该如何解决这个问题?

英文:

I can't seem to use dotnet ef core tools...

I somehow created the database on this project some time ago. I just tried to update it after some DB changes with:

dotnet ef database update --connection "[connection string]"

but I get:

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 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.

So I tried:

dotnet tool install --global dotnet-ef

But it told me the tools were already installed. So I uninstalled, then reinstalled, both of which said they were successful. And for good measure I did:

dotnet tool update --global dotnet-ef

which responded with:

Tool 'dotnet-ef' was reinstalled with the latest stable version (version '7.0.5').

But the command still doesn't work and

dotnet tool list

shows nothing.

How can I fix this?

答案1

得分: 2

dotnet tool list无法正常工作的原因是该命令仅显示当前目录中安装的工具。为了显示所有全局安装的工具,您需要执行命令dotnet tool list --global

通常,当您尝试更新 EF 时,会执行dotnet tool update --global dotnet-ef,因为您执行的命令重新安装了该工具。

尝试重新打开您的IDE或正在使用的终端,因为它可能需要重新启动才能正常工作。


最终解决方案(已更新)

问题

> 缺少dotnet工具目录的环境路径变量。

解决方案

> 将全局安装的dotnet工具目录的执行路径添加到设备环境变量中。

不同操作系统下的全局工具目录:

  • Linux/macOS ---> $HOME/.dotnet/tools
  • Windows ---> %USERPROFILE%\.dotnet\tools
英文:

The reason why dotnet tool list is not working is that that command will only show the tools installed in the current directory. In order to show all the globally installed tools you have to execute the command dotnet tool list --global.

Normally when you try to update EF you execute dotnet tool update --global dotnet-ef, since the command you executed reinstalled the tool.

Try to reopen your IDE or the terminal you are using, since it may require a restart in order to work.


Final Solution (Updated)

Issue

> The environment path variable to the dotnet tools directory was missing.

Solution

> Adding the execution path to the globally installed dotnet tools directory to the device environment variables.

Global Tools Directory per OS:

  • Linux/macOS ---> $HOME/.dotnet/tools
  • Windows ---> %USERPROFILE%\.dotnet\tools

huangapple
  • 本文由 发表于 2023年4月17日 22:35:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76036306.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定