Rogerio Schmitt
Rogerio Schmitt

Reputation: 1275

How to properly install dotnet ef on Ubuntu?

I'm trying to install dotenet ef on Ubuntu 20.4.1 LTS.

First, I've installed the tool globally:

dotnet tool install --global dotnet-ef

As it was not working, then I added this PATH reference to my dotnet tools folder on my .bashrc file:

export PATH="$PATH:$HOME/.dotnet/tools/"

As suggested here: Cannot find command 'dotnet ef'?

Yet when I try to run dotnet ef, I get this error message:

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

Interestingly if I try to install it again I'm informed it is already installed.

Tool 'dotnet-ef' is already installed.

But if I try to list my installed tools with dotnet tool list I get an empty result:

Tool 'dotnet-ef' is already installed.

I have also checked my ~/.dotnet/tools/ folder and it is empty.

What am I missing here?

Upvotes: 4

Views: 4954

Answers (3)

Andre Morata
Andre Morata

Reputation: 397

While using Fish, use fish_add_path $HOME/.dotnet/tools/ after installing ef globally.

Upvotes: 0

Dzmitry Atkayey
Dzmitry Atkayey

Reputation: 402

Found the solution.

Add the following to the .bashrc/.zshrc

export PATH="$PATH:$HOME/.dotnet/tools/"

Upvotes: 4

Christian Reizner
Christian Reizner

Reputation: 56

I had the same problem on Ubuntu. I had installed dotnet manually. For some reason dotnet-ef looks for dotnet in "/usr/share/dotnet". So I had to install the dotnet-sdk exactly in the directory "/usr/share/dotnet", change the PATH accordingly and also set DOTNET_ROOT to this directory. Then dotnet-ef also worked.

Btw: You can set the installation path of dotnet-ef manually by --tool-path "$HOME/.dotnet/tools" if --global does not work.

Upvotes: 2

Related Questions