efcore: Entity Framework Tools not working after update to EF Core 1.1.0

Steps to reproduce

Update .NET Core packages (including ASP.NET Core and EF Core) in solution from 1.0.0 to 1.1.0.

Update package "Microsoft.EntityFrameworkCore.Tools" : "1.0.0-preview2-final" to "Microsoft.EntityFrameworkCore.Tools" : "1.1.0-preview4-final". Alternatively, change to package "Microsoft.EntityFrameworkCore.Tools.DotNet" : "1.1.0-preview4-final" as per the anncouncement.

The issue

When using the Microsoft.EntityFrameworkCore.Tools package and trying to invoke any dotnet ef command on the console, the error message is thrown:

No executable found matching command “dotnet-ef”.

When using the Microsoft.EntityFrameworkCore.Tools package and trying to invoke any entity framework tooling command on the Package Manager Console, the same error is thrown:

PM> add-migration Test No executable found matching command “dotnet-ef”

When trying to install the package Microsoft.EntityFrameworkCore.Tools.DotNet via Package Manager Console, the following error message is thrown:

install-package : Package ‘Microsoft.EntityFrameworkCore.Tools.DotNet 1.1.0-preview4-final’ uses features that are not supported by the current version of NuGet. To upgrade NuGet, see http://docs.nuget.org/consume/installing-nuget.

When trying to install the package Microsoft.EntityFrameworkCore.Tools.DotNet via project.json, the following error is logged to the Output window:

Package Microsoft.EntityFrameworkCore.Tools.DotNet 1.1.0-preview4-final is not compatible with net461 (.NETFramework,Version=v4.6.1). Package Microsoft.EntityFrameworkCore.Tools.DotNet 1.1.0-preview4-final supports: netcoreapp1.0 (.NETCoreApp,Version=v1.0) One or more packages are incompatible with .NETFramework,Version=v4.6.1.

Further technical details

EF Core version: 1.1.0 Operating system: Win10 Visual Studio version: VS 2015 Update 3

Other details about my project setup:

PM> dotnet --version 1.0.0-preview2-1-003177

I have an ASP.NET Core application targeting the full .NET framework. Thus I need the net461 entry in the frameworks section of project.json.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 3
  • Comments: 37 (14 by maintainers)

Most upvoted comments

I haven’t been able to use the 1.1.0 version, I had to use:

"Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final"

So I have all my entityframework dependencies with 1.1.0 version except the tools and the design dll. That’s the only way I made it work.

After trying alot of combinations, this is what works with my framework:

“dependencies”: { “System.Net.Http”: “4.3.0”, “YeshuApp.Models”: “1.0.0-*”, “Microsoft.NETCore.App”: “1.1.0”, “Microsoft.ApplicationInsights”: “2.2.0”, “Microsoft.EntityFrameworkCore”: “1.1.0”, “Microsoft.EntityFrameworkCore.SqlServer”: “1.1.0”, “Microsoft.EntityFrameworkCore.Relational”: “1.1.0”, “Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore”: “1.1.0”, “Microsoft.EntityFrameworkCore.SqlServer.Design”: “1.1.0”, “Newtonsoft.Json”: “9.0.1”, “Microsoft.EntityFrameworkCore.Tools.DotNet”: “1.0.0-preview3-final”, “Microsoft.EntityFrameworkCore.Design”: “1.0.0-preview2-final”, “Microsoft.EntityFrameworkCore.Tools”: “1.0.0-preview2-final” }, “frameworks”: { “netcoreapp1.1”: { “imports”: [ “dotnet5.6”, “portable-net45+win8” ] } }, “tools”: { “Microsoft.EntityFrameworkCore.Tools”: “1.0.0-preview2-final”, “Microsoft.EntityFrameworkCore.Tools.DotNet”: “1.0.0-preview2-final”, “Microsoft.EntityFrameworkCore.Design”: “1.0.0-preview2-final” },

Hello all,

My team was able to resolve this issue updating the project.json file in the migrations project. We removed the following from dependencies: , “Microsoft.EntityFrameworkCore.Tools”: { “type”: “build”, “version”: “1.1.0-preview4-final” }

We added the following to tools

“tools”: { “Microsoft.EntityFrameworkCore.Tools”: “1.1.0-preview4-final”, “Microsoft.EntityFrameworkCore.Tools.DotNet”: “1.1.0-preview4-final” },

you are then able to run the following command to deploy from your migrations project using your web project.

dotnet ef --startup-project …<Web Project>\ database update

my example: dotnet ef --startup-project …\CoreServices.Web\ database update

I hope this helps you guys as well.

Jason

I think I have roughly the same issue:

I have a ASP.NET Core project that runs ONLY on the Full .NET Framework 4.6.1 (not .NET Core).

However, I cannot make the tooling work after upgrading to 1.1 (Using the Package Manager only).

My DbContext is located in a library project that is referenced by the main web project.

I have tried with: “Microsoft.EntityFrameworkCore.Tools”: -> When I use this, I am simply told the following: Could not find assembly ‘C:\path\to\solution\ProjectName.\bin\Debug\net461\win7-x64\ProjectWithContextName.exe’.

“Microsoft.EntityFrameworkCore.Tools.DotNet”: -> This simply does not target the full .NET, so I cannot use it.

I have also tried updating to the latest nuget package manager. This does not solve the problem.

If I set the ‘Default project’ to my main web project in the Package Manager Console and attempt to execute the command, I am told: No DbContext named ‘ApplicationDbContext’ was found.

So I think the tooling can at the very least be found.

@solenovex No, you placed “Microsoft.EntityFrameworkCore.Tools” under tools, it needs to be “Microsoft.EntityFrameworkCore.Tools.DotNet”

@solenovex You also need to upgrade “Microsoft.EntityFrameworkCore.Tools.DotNet” to “1.1.0-preview4-final” in the tools section

I am having similar issues running add-migration from package manager console. I have updated Tools to 1.1.0-preview4-final.

PM> add-migration Test Cannot execute this command because the version of Microsoft.EntityFrameworkCore.Design installed is not compatible with this tool.

I have this in my dependencies:

"Microsoft.EntityFrameworkCore.Design": "1.1.0"

I’ve reproduced this with a completely new project, it works using netcoreapp1.1 but not with net46 or net451. These are the project.jsons, the topmost one works and the bottom one does not:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.EntityFrameworkCore.Design": {
      "version": "1.1.0",
      "type": "build"
    }
  },
  "tools": {
    "Microsoft.EntityFrameworkCore.Tools.DotNet": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    }
  },

  "frameworks": {
    "netcoreapp1.1": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.1"
        }
      }
    }
  }
}

Not working:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.EntityFrameworkCore.Design": {
      "version": "1.1.0",
      "type": "build"
    }
  },
  "tools": {
    "Microsoft.EntityFrameworkCore.Tools.DotNet": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    }
  },

  "frameworks": {
    "net46": { }
  }
}

It seems like support for net46 is not complete?

@MikaelGRA - Thanks for Whatever 😉

I cloned the repo. Opened solution in VS. Following is the output from PMC afterwards.

PM> dotnet restore
log  : Restoring packages for D:\Whatever\src\Whatever.Data\project.json...
log  : Restoring packages for D:\Whatever\src\Whatever\project.json...
log  : Restoring packages for tool 'Microsoft.EntityFrameworkCore.Tools' in D:\Whatever\src\Whatever.Data\project.json...
log  : Restoring packages for tool 'BundlerMinifier.Core' in D:\Whatever\src\Whatever\project.json...
log  : Writing lock file to disk. Path: D:\Whatever\src\Whatever.Data\project.lock.json
log  : D:\Whatever\src\Whatever.Data\project.json
log  : Restore completed in 2804ms.
log  : Restoring packages for tool 'Microsoft.AspNetCore.Razor.Tools' in D:\Whatever\src\Whatever\project.json...
log  : Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in D:\Whatever\src\Whatever\project.json...
log  : Restoring packages for tool 'Microsoft.EntityFrameworkCore.Tools' in D:\Whatever\src\Whatever\project.json...
log  : Restoring packages for tool 'Microsoft.Extensions.SecretManager.Tools' in D:\Whatever\src\Whatever\project.json...
log  : Restoring packages for tool 'Microsoft.VisualStudio.Web.CodeGeneration.Tools' in D:\Whatever\src\Whatever\project.json...
log  : Writing lock file to disk. Path: D:\Whatever\src\Whatever\project.lock.json
log  : D:\Whatever\src\Whatever\project.json
log  : Restore completed in 10719ms.
PM> Add-Migration Test
Your target project 'Whatever' doesn't match your migrations assembly 'Whatever.Data'. Either change your target project or change your migrations assembly.
Change your migrations assembly by using DbContextOptionsBuilder. E.g. options.UseSqlServer(connection, b => b.MigrationsAssembly("Whatever")). By default, the migrations assembly is the assembly containing the DbContext.
Change your target project to the migrations project by using the Package Manager Console's Default project drop-down list, or by executing "dotnet ef" from the directory containing the migrations project.
PM> Add-Migration Test
To undo this action, use Remove-Migration.
PM> 

Due the first error the only code I had to modify was

services.AddDbContext<ApplicationDbContext>( options =>
        options.UseSqlServer( 
        Configuration.GetConnectionString( "DefaultConnection" ), b => b.MigrationsAssembly("Whatever")
        //, sql => sql.MigrationsAssembly( migrationAssembly )  // Do not believe this is required...
        ) );

Let me know if you still face any issues.

What about Visual Studio 2017?

project.json is replaced with project.csproj

but dotnet ef is still looking for project.json

After 1.0.0-preview2-final, we split the package into two–the one that should be under dependencies (Microsoft.EntityFrameworkCore.Tools) and the one that should be under tools (Microsoft.EntityFrameworkCore.Tools.DotNet)

@Artur-A tools is specifically for registering .NET CLI Tools, so only Microsoft.EntityFrameworkCore.Tools.DotNet should be in there. Microsoft.EntityFrameworkCore.Design and Microsoft.EntityFrameworkCore.Tools both go as regular dependencies.

https://github.com/aspnet/EntityFramework/issues/7071 tracks the Unrecognized option '--config' issue

I’m using the command line, I have the same issue. After Installing .netcore 1.1 and Uninstalling .netcore 1.0 Then I upgrade the eftools(“Microsoft.EntityFrameworkCore.Tools”) to version “1.1.0-preview4-final”. When I run “dotnet ef xxx”, it shows "No executable found matching command “dotnet-ef”. Environment: windows 10, VSCode, command line. (No visual studio installed).