0

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?

Pete
  • 6,585
  • 5
  • 43
  • 69

1 Answers1

2

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
Bram
  • 511
  • 1
  • 6
  • 22
  • `dotnet tools list --global` works to list it, but it still won't run it. I closed and reopened the IDE. I've used other command prompt windows. It says it's installed, but acts like it isn't. – Pete Apr 17 '23 at 14:58
  • Could you check [this answer?](https://stackoverflow.com/a/60938208/16596000) – Bram Apr 17 '23 at 15:03
  • 1
    Thanks. That fixed it: adding: `c:\Users\[username]\.dotnet\tools` to the path worked. Not sure how it got removed... – Pete Apr 17 '23 at 15:14