Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF Core tools won't install properly

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?

like image 548
Pete Avatar asked Oct 28 '25 14:10

Pete


1 Answers

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
like image 141
Bram Avatar answered Oct 30 '25 14:10

Bram