Header add

In this article we will learn if you get error to run entity framework in asp .NET Core.


When run this command in below.

dotnet ef migrations add InitialCreate

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.

  • I excluded the first item since I copied the command.

  • I excluded the second item because the package Microsoft.EntityFrameworkCore.SqlServer is installed.

  • I excluded the third item because I get the help section when invoking dotnet

See the announcement for ASP.NET Core 3 Preview 4, which explains that this tool is no longer built-in and requires an explicit install: 

The dotnet ef tool is no longer part of the .NET Core SDK

This change allows us to ship dotnet ef as a regular .NET CLI tool that can be installed as either a global or local tool. For example, to be able to manage migrations or scaffold a DbContext, install dotnet ef as a global tool typing the following command:

dotnet tool install --global dotnet-ef

To install a specific version of the tool, use the following command:

dotnet tool install --global dotnet-ef --version 3.1.4

This change allows us to distribute and update dotnet ef as a regular .NET CLI tool on NuGet, consistent with the fact that the EF Core 3.0 is also always distributed as a NuGet package.

In addition, you might need to add the following NuGet packages to your project:

 

Post a Comment

Previous Post Next Post