Reputation: 7215
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.
Upvotes: 0
Views: 2178
Reputation: 7239
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
Upvotes: 0
Reputation: 7135
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
.
Upvotes: 2