Run commands:
dotnet new mvc
dotnet add package Microsoft.EntityFrameworkCore
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL
dotnet add package Microsoft.EntityFrameworkCore.Tools.DotNet
Inherit a new class from DBContext and add a connection string in your appsettings.json (shouldn't matter)
ef command should run
No executable found matching command "dotnet-ef"
dotnet --info
output:
.NET Command Line Tools (1.0.3)
Product Information:
Version: 1.0.3
Commit SHA-1 hash: 37224c9917
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\1.0.3
Followed all steps recommended by Microsoft here -
https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/migrations
http://thedatafarm.com/data-access/no-executable-found-matching-command-dotnet-ef/
I found a workaround for this issue. I manually added the following entry in the .csproj file -
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
</ItemGroup>
This entry was already there when I added the DotNet package but it was not in the DotNetCliToolReference section. It is clearly a bug.
No. This is not a bug. This is how project tools work. They need to be listed in the DotnetCliToolReference. We have a bug in NuGet tracking adding an option to dotnet add that would add a DotnetCliToolReference for you, instead of a PackageReference.
In the Versioning of this package there is a 1.1.0-preview4-final available that seems to be looking for project.json and does not "recognise" / "consider2" .csproj file. Version 1.0.0 works fine.
This is my .project.csproj file. But I am still getting the error. Anyone can help me? Thanks in advance for any help. :)
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.2" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
</ItemGroup>
</Project>
Most helpful comment
I found a workaround for this issue. I manually added the following entry in the .csproj file -
<ItemGroup> <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" /> </ItemGroup>
This entry was already there when I added the DotNet package but it was not in the DotNetCliToolReference section. It is clearly a bug.