"No executable found matching command dotnet-ef" error with EF Core database-first

even picture even · Mar 20, 2017 · Viewed 8.7k times · Source

As you know, the newest version of Visual Studio 2017 abandons the 'project.json' and uses .csproj instead.

I'm using the RTM version and want to generate model from an exist database, following this guide. I got an error on the last step:

The Entity Framework Core commands for the Package Manager Console don't yet support csproj-based .NET Core projects. Use the .NET Command Line Tools (i.e. dotnet ef) instead. For more details, see https://go.microsoft.com/fwlink/?linkid=834381.

Following the error, I used the link it mentioned to switch to dotnet ef. Here is my package manager command:

PM> dotnet ef dbcontext scaffold "Server=.;Database=Jumpstart;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer

Then the error comes again:

dotnet : No executable found matching command "dotnet-ef"

I used the help command, I found that dotnet does not have a command called ef.

I just want to generate a model from an existing database.

Answer

PROTOCOL picture PROTOCOL · Mar 28, 2017

Follow this tutorial

https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/migrations

I had the same problem. Just edited the ItemGroup section in .csproj like this

<ItemGroup>
   <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
</ItemGroup>