You intended to execute a .NET program, but dotnet-ef does not exist

The Problem.

I was trying to create a scaffold template for the EF core from the console by running a command like

dotnet ef dbcontext scaffold "Data Source=SAILENOVO;Initial Catalog=HPlusSports;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False" Microsoft.EntityFrameWorkCore.SqlServer -o Models

I was getting an error message,

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 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 solution:

Run the following to have the dotnet-ef tool installed.

dotnet tool install --global dotnet-ef

Finally, the scaffolding template worked with the necessary models created.

Leave a comment