0

There are many people that have asked this question before on SO. For the last 3 hours I have sequentially tried each solution, and I get the same No executable found matching command "dotnet-ef" each time. I'd like to understand how to run the command and have it actually execute.

But first a little background:

I am learning how to use ASP.Net Core 1.1 MVC and Entity Framework Core. It is a Microsoft tutorial that can be found here.

The completed tutorial can be downloaded from git, as instructed. Performing these steps I open the download project and follow the steps in the readme.md file in the project root folder. It states the following:

After downloading the project, create the database by entering dotnet ef database update at a command-line prompt

Which I attempted. I used visual studio developer command prompt (as admin) and first change directory to the project root, where the appsettings.json and *.csproj file are located. I then typed in the following:

C:\Users\username\Downloads\Docs-master\aspnetcore\data\ef-mvc\intro\samples\cu-final>dotnet ef database update

No executable found matching command "dotnet-ef"

According to the tutorial, this should "work" as-is.

What is strange to me is that if I run the following command I get output, which indicates to me that dotnet.exe is working.

C:\Users\username\Downloads\Docs-master\aspnetcore\data\ef-mvc\intro\samples\cu-final>dotnet --version

1.0.4

I am using Windows 10 and Visual Studio 2017 CE Version 15.2. I have both the ASP.NET and web development and .Net Core cross-platform development workloads installed.

I am also using .Net Framework Version 4.6.01586.

Dustin Kingen
  • 19,074
  • 6
  • 47
  • 90
sapbucket
  • 5,775
  • 10
  • 47
  • 85
  • Possible duplicate of [#37276882](https://stackoverflow.com/a/45765523/1233379): in short words, you need to manually edit your project configuration file and add a reference to the Tools / Tools.DotNet packages (as VS2015/VS2017 won't do that automatically). For further info, [read here](http://www.ryadel.com/en/no-executable-found-matching-command-dotnet-ef-error-in-visual-studio-2017-and-net-core-2-vs2017-entity-framework/). – Darkseal Aug 19 '17 at 05:57

2 Answers2

2

Make sure you restore first so that the ef tools become available:

Execute dotnet restore and wait for it to restore successfully, then execute dotnet ef database update.

Alaa Masoud
  • 6,922
  • 3
  • 37
  • 55
0

Microsoft.EntityFrameworkCore.Tools.DotNet needs to be added to your project. Right click the project and select Edit *.csproj. Then, add the following:

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

Note: the version is the latest at the time of this post and will likely change in the future.

These tools can only be added by editing the .proj directly at this time.

The easiest way it run commands is to right click the project and Open Folder in File Explorer. Then, type cmd in the address bar of the File Explorer to open a command prompt in that folder. Now use the following command to create the initial migration:

dotnet ef migrations add InitialCreate

Todd Skelton
  • 4,994
  • 2
  • 30
  • 39
  • Is there a way to determine which Version that I should be using? When I run the migration command I see the following: "C:\Users\username\Documents\Visual Studio 2017\Projects\CUPrimer\CUPrimer>dotnet ef migrations add InitialCreate Version for package `Microsoft.EntityFrameworkCore.Tools.DotNet` could not be resolved." – sapbucket Jul 14 '17 at 15:24
  • @sapbucket I'm using Visual Studio 2017 Preview with .Net Core 2.0 preview. The version should match the version of .Net core you are using. – Todd Skelton Jul 14 '17 at 17:17