dotnet ef command no longer works after upgrading to Visual Studio 16.3.0
Asked Answered
A

1

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.

Acervate answered 24/9, 2019 at 9:23 Comment(0)
H
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
Humpy answered 24/9, 2019 at 9:25 Comment(5)
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?Spoke
@Spoke Why use the 3.0 SDK though? Just use 2.x that matches your code, you will have it installed anyway.Humpy
@Humpy - 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.Spoke
@Humpy 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.Spoke
So reading here 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-manifestSpoke

© 2022 - 2024 — McMap. All rights reserved.