Sdk: Error message 'No executable found matching command "dotnet-ef"' when executing 'dotnet ef'

Created on 18 Feb 2017  路  5Comments  路  Source: dotnet/sdk

Steps to reproduce

  • Open this manual: .NET Core - New Database
  • Follow the Steps "Prerequisites" and "Create a new project"
  • Since there is no project.json file, skip the step "Install Entity Framework" and add the following to the .csproj file:
  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="1.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.0">
      <PrivateAssets>All</PrivateAssets>
    </PackageReference>
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
    <PackageReference Include="Microsoft.NETCore.App" Version="1.1.0" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.1.0-preview4" />
  </ItemGroup>
  • Run dotnet restore
  • Follow the step "Create your database"

Expected behavior

  • The file /Blogging.db gets created

Actual behavior

  • The error message No executable found matching command "dotnet-ef" appears.

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-rc3-004530)

Product Information:
 Version:            1.0.0-rc3-004530
 Commit SHA-1 hash:  0de3338607

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-rc3-004530

Most helpful comment

the issue is that I've used the wrong tool reference. This one works:

<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild3-final" /> 

All 5 comments

There is a similar issue after upgrading the version of the solution:

C:\Users\鈥Backend> dotnet ef
System.IO.FileNotFoundException: Could not find file 'C:\Users\鈥Backend\project.json'.
File name: 'C:\Users\鈥Backend\project.json'
   at System.IO.Win32FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
   at System.IO.Win32FileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at Microsoft.DotNet.ProjectModel.ProjectReader.GetProject(String projectPath, ProjectReaderSettings settings)
   at Microsoft.DotNet.ProjectModel.ProjectContext.<CreateContextForEachFramework>d__45.MoveNext()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at NuGet.Frameworks.FrameworkReducer.GetNearestInternal(NuGetFramework framework, IEnumerable`1 possibleFrameworks)
   at NuGet.Frameworks.FrameworkReducer.GetNearest(NuGetFramework framework, IEnumerable`1 possibleFrameworks)
   at NuGet.Frameworks.NuGetFrameworkUtility.GetNearest[T](IEnumerable`1 items, NuGetFramework framework, IFrameworkNameProvider frameworkMappings, IFrameworkCompatibilityProvider compatibilityProvider, Func`2 selector)
   at Microsoft.EntityFrameworkCore.Tools.DotNet.Internal.ProjectContextFactory.SelectCompatibleFramework(NuGetFramework target, IEnumerable`1 contexts)
   at Microsoft.EntityFrameworkCore.Tools.DotNet.Internal.ProjectContextFactory.Create(String filePath, NuGetFramework framework, String configuration, String outputDir)
   at Microsoft.EntityFrameworkCore.Tools.DotNet.Internal.DispatchOperationExecutor.Execute(CommandLineOptions options)
   at Microsoft.EntityFrameworkCore.Tools.DotNet.Program.Main(String[] args)
Could not find file 'C:\Users\鈥Backend\project.json'.

Clearly there is no project.json file, since it is in the .csproj file. However, this might be an issue with the

    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.1.0-preview4" />

entry and not with the CLI tools itself.

the issue is that I've used the wrong tool reference. This one works:

<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild3-final" /> 

Well... that does solved the "dotnet ef" issue, but now i'm getting a "project.json file does not exists"... i'm using VS for mac by the way

if it is searching for the project.json file, then it's an old version of the tools. however, the version for Mac might not be finished yet.

Was this page helpful?
0 / 5 - 0 ratings