entity-framework.net-corewindows-subsystem-for-linuxef-core-3.0

dotnet-ef does not exist - Windows 10 WSL (Ubuntu)


I've been testing dotnet core 3 in different OS like Windows and Linux(Ubuntu). All of them are working fine with EF Core!

However, I decided to give a chance to Windows WSL - Windows Subsystem for Linux and see how it works. That's why I'm here!

The problem with WSL and Ubuntu 18.04 is:

I installed EF Core globally and restarted the terminal. * Up to this point, the EF version is 3.1.4

> dotnet tool install --global dotnet-ef

I get the following error when I try to run any dotnet ef command:

> dotnet ef database update

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.

Has anyone faced the same error using Windows WSL and Ubuntu 18.04?


Solution

  • Finally I found the solution!

    I've tried to export the PATH variable export PATH="$PATH:$HOME/.dotnet/tools" as @kapsiR mentioned. However, it was valid for a single terminal session only. So if I close the terminal and open again, the $PATH configuration disappears.

    The solution that works for me:

    1. cd /home/yourUserName
    2. Edit the file .zshrc and add this line export PATH="$PATH:$HOME/.dotnet/tools/". NOTE: I'm using zsh shell in this case. You should change it if you are using a different one.
    3. Restart your terminal