ASP.NET Core 2 migration error. No executable found matching "dotnet-ef" command

When I want to add a transition to my project, I got the following error:

dotnet: no executable found the corresponding dotnet-ef command

To do this, I add the following package, but I still get the same error.

Microsoft.EntityFrameworkCore.Design(2.0.0)
Microsoft.EntityFrameworkCore.Tools.DotNet(2.0.0)

I found some solution, but they are based on .net-core-1, and in .net-core-2we do not have a file project.json.

update:

Here is my .csproj file:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Extensions.Configuration">
      <HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.configuration\2.0.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll</HintPath>
   </Reference>
</ItemGroup>

</Project>
+4
source share
3 answers

To work dotnet ef, you need to add an element DotNetCliToolReferencein the .csprojfollowing way:

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

ItemGroup, - :

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

, dotnet ef , .csproj.

+7

To answer

, . cd'ing , csproj , - , . dotnet ef .

+3

, , [ "dotnet-" ] . :

No executable found matching command "dotnet-My"

And .... it turned out that my application name was "My application". Make sure the assembly name does not contain spaces. I changed it to "MyApp" and downloaded it correctly.

0
source

Source: https://habr.com/ru/post/1685073/


All Articles