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.
Follow this tutorial
https://learn.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>
Accepted answer is the most probable cause of the error message. However, besides adding the proper reference within .csproj
file also make sure that the current directory from Package Manager Console
points to ASP.NET Core project, otherwise any dotnet ef
command will fail with the error mentioned in the OP title.
My issue was solved by changing tools
to:
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final"
},
Then execute these 2 commands:
dotnet restore
- to restore packagesI solved the problem
in all answer mentioned adding Tools DotNet but not solved my problem because missed some command I mention below
The EF Core .NET Command Line Tools are installed by manually editing the *.csproj file.
Add Microsoft.EntityFrameworkCore.Tools.DotNet as a DotNetCliToolReference. See sample project below.
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
</ItemGroup>
for core version 2 changed the version but after that should run 2 commands too
then importatn part in all answer missing (this command solved my problem in visuall studio 2017)
1 - Execute dotnet add package Microsoft.EntityFrameworkCore.Design
2 - Execute dotnet restore
. If restore does not succeed, the tools may not have installed correctly.
more information https://learn.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With