question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Entity Framework tools -- "No executable found matching command 'dotnet-ef'"

See original GitHub issue

Steps to reproduce

  1. Install RC4 VS 2017
  2. Create an ASP.NET Core/ASP.NET Core web project.
  3. Add EF tools to .csproj <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.Dotnet" Version="1.0.0-msbuild3-final" />
  4. In project folder run dotnet restore
  5. Try to run EF tools with “dotnet ef” commands.

Expected behavior

EF tools run

Actual behavior

No executable found matching command "dotnet-ef"

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-rc4-004802)

Product Information:
 Version:            1.0.0-rc4-004802
 Commit SHA-1 hash:  2384b5f1a8

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.0-rc4-004802

.csproj contents:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>

  <PropertyGroup>
    <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.0" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.Dotnet" Version="1.0.0-msbuild3-final" />
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild3-final" />
  </ItemGroup>

</Project>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
douglasg14bcommented, Jul 22, 2017

@emgarten 1.0.1 has the same issue, it’s pretty frustrating, pages of google results and no working solution yet…

1reaction
emgartencommented, Feb 15, 2017

Cause

This is caused by a case sensitive comparison on the package id. The repro steps use a lowercase n in Dotnet while the actual package contains an upper case N. https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Tools.DotNet/1.1.0-preview4-final

Package ids should be compared case insensitively. The current code causing the issue is here: https://github.com/dotnet/cli/blob/4b00570f68c0f9709dec97ef6c10f439b7075e96/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs#L152

Fix

After changing to the code below dotnet ef runs fine:

var toolLibrary = toolLockFile.Targets
    .FirstOrDefault(
        t => s_toolPackageFramework == t.TargetFramework)
    ?.Libraries.FirstOrDefault(l => 
                   StringComparer.OrdinalIgnoreCase.Equals(l.Name, toolLibraryRange.Name));

Note the target framework compare was also case sensitive which could cause issues. The best way to check framework equality is to let NuGetFramework perform the comparison using Equals or ==.

Workarounds

Changing the DotNetCliToolReference to use the exact casing also solves the issue.

However since these tools can only be added manually currently, and there is no intellisense or UI to help with this it users may often enter these ids incorrectly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No executable found matching command "dotnet-ef"
Entity Framework Core 1.0. You should just need to update the tools section of your project.json file to include this: "Microsoft.
Read more >
No executable found matching command "dotnet-ef" even ...
I want to Migrate my Database with Models. I am using EF Core 2.0 Preview. dotnet ef migrations add InitialCreate dotnet : No...
Read more >
Fix "No executable found matching command dotnet-ef ...
How to fix the "No executable found matching command dotnet-ef" error in Visual Studio 2017 when using Entity Framework Core 2.x with ASP....
Read more >
.NET Core Errors - Part One - Solution For “No Executable ...
In this post, we will see how to resolve the error, No executable found matching command “dotnet-ef”. This error comes when we want...
Read more >
Troubleshooting the dotnet ef command for EF Core ...
No executable found matching command "dotnet-ef" ... I recorded my Entity Framework Core: Getting Started course on Pluralsight while VS2017 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found