The “No executable found matching command dotnet-ef” error
There is a nasty issue affecting most .NET Core-based Visual Studio projects that can prevent the dotnet ef commad from working properly.
More specifically , you can be prompted by the following error message when trying to execute that command.
No executable found matching command “dotnet-ef”
If you experience this issue, try to check the following :
Double-check that you properly added the Microsoft.EntityFrameworkCore.Tools and the Microsoft.EntityFrameworkCore.Tools.DotNet package libraries (as explained earlier) , as they are required for the command to work.
Ensure that you are issuing the dotnet ef command in the project’s root folder-the same one that also contains the <ProjectName>.csproj file , it won’t work anywhere else.
If both of these checks hit their marks , try this workaround
<DotNetCliToolReference Include=”Microsoft.EntityFrameworkCore.Tools.DotNet” version=”2.0.0” />
The <ItemGroup> element is just a container here;you need to look for the highlighted lines. Needless to say , the Version value will change when using a different or more recent EF Core release. Be aware that these elements can have a slightly different syntax.
However, they definitely need to be there , if you can’t find them , you will know why the dotnet ef command is not working. Fix that unwanted behaviour by manually adding them to your project configuration file. They must be wrapped within the <ItemGroup> block, so yoi can either put them together in a group with other <DotNetCliToolReference> element(If there is at least one), or add a whole net <ItemGroup> block.