2

This happened at home first, so I thought maybe it was an issue with my desktop PC at home. But now that I am back at work, I tried the upgrade and got the same thing.

Screenshot before upgrade

dotnet ef command

Screenshot after upgrading Visual Studio

dotnet ef command

The error I get is:

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.

Any ideas on why this happens? And how do I get back the dotnet ef command. I mean must have been in the $PATH previously, otherwise it wouldn't have worked before.

Community
  • 1
  • 1
J86
  • 11,751
  • 29
  • 115
  • 194

1 Answers1

10

This is a breaking change in Entity Framework Core 3.0:

The EF Core command-line tool, dotnet ef, is no longer part of the .NET Core SDK.

...

Starting in 3.0, the .NET SDK does not include the dotnet ef tool, so before you can use it you have to explicitly install it as a local or global tool.

You need to install the Entity Framework Core Tools. To install it globally, run this on the command line:

dotnet tool install --global dotnet-ef
Community
  • 1
  • 1
DavidG
  • 95,392
  • 10
  • 185
  • 181
  • What if I have an older project (on Core 2.0) that I need to enhance. Can I add an `ef migration` to a 2.0 project with the 3.0 SDK's tool? – Grandizer Oct 18 '19 at 14:58
  • @Grandizer Why use the 3.0 SDK though? Just use 2.x that matches your code, you will have it installed anyway. – DavidG Oct 18 '19 at 15:00
  • @DavidG - perfect, but I am getting this `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.` and trying to figure it out. – Grandizer Oct 18 '19 at 15:01
  • @DavidG I am find to use the 2.x but it is not obvious how to force it to access that version based on the above error message. This was my command to add a migration `dotnet ef migrations add EmployeeUtilization -s ..\Almanac` which has worked for the entire project until I started working on a .NET Core 3 project and installed that SDK. – Grandizer Oct 18 '19 at 15:03
  • 1
    So reading [here](https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet) I did `dotnet tool install --local --version 2.0 dotnet-ef` from the base of my repo. That worked! Did this prior, but not sure if I needed to: `dotnet new tool-manifest` – Grandizer Oct 18 '19 at 15:19