Cannot create initial migration with dotnet ef command in .NET core

.NET Core Logo.svg
By Jason Groce – https://github.com/dotnet/docs/blob/cb475ed45f881e9462e34764480d3b0ebce85e91/docs/images/hub/netcore.svg, Public Domain, Link

The new .NET Core 3.0 was released on September 23, 2019, with lots of new features and new changes. Often times, those new changes will not cause any trouble but sometimes they do. And there is one specific change in this new update that will give you a headache if you update to .NET Core 3.0 without reading what has been changed in the new release, and this change is related to the “dotnet ef” command-line tool.

Starting in .NET Core 3.0, the “dotnet ef” command-line tool is removed from the .NET Core SDK. If you updated your .NET Core SDK to the latest version and when you execute EF Core migration or scaffolding commands, you will get the following error:

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.

The fix to this error is to manually install the “dotnet-ef” command-line tool by running the following command:

To install the tool as a global tool:

dotenet tool install --global dotnet-ef --version 3.0.0

It is optional to specify the version in the command. If you want to install the tool as a local tool, just remove “–global” option in the above command.

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Junaid Ali Syed Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Junaid Ali Syed
Guest
Junaid Ali Syed

updated dotnet tool install –global dotnet-ef –version 3.0.0