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

Created on 1 May 2017  路  4Comments  路  Source: dotnet/sdk

Steps to reproduce

  1. Download dotnet SDK for Windows x64 as on 1 May 2017 from https://www.microsoft.com/net/download/core#/sdk
  2. Make sure dotnet 1.1 latest sdk is installed
  3. Install Microsoft's spa packages by running :
    dotnet new --install Microsoft.AspNetCore.SpaTemplates::*
  4. Run commands:
    dotnet new mvc
    dotnet add package Microsoft.EntityFrameworkCore
    dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL
    dotnet add package Microsoft.EntityFrameworkCore.Tools.DotNet

  5. Inherit a new class from DBContext and add a connection string in your appsettings.json (shouldn't matter)

  6. Run command :
    dotnet ef

Expected behavior

ef command should run

Actual behavior

No executable found matching command "dotnet-ef"

Environment data

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/

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.

All 4 comments

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>

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clairernovotny picture clairernovotny  路  3Comments

noelitoa picture noelitoa  路  3Comments

natemcmaster picture natemcmaster  路  3Comments

fmorriso picture fmorriso  路  3Comments

thomaslevesque picture thomaslevesque  路  3Comments