Cannot add EntityFrameworkCore Tools 1.0.1 to class library in Visual Studio 2017

.net-core entity-framework-core visual-studio-2017


I am using the latest VS2017 update with donet core 1 I try to create an ef migration to my project with the command dotnet ef but I get

dotnet : No executable found matching command "dotnet-ef"

I then remove any reference to EntityFrameworkCore it from my Class Library csproj (.Net Core) and wanted to add the package Microsoft.EntityFrameworkCore.Tools.DotNet 1.0.1 . However I refuses and I get the following error

Severity Code Description Project File Line Suppression State Error Package 'Microsoft.EntityFrameworkCore.Tools.DotNet 1.0.1' has a package type 'DotnetCliTool' that is not supported by project 'MyVS2017Project'. 0 I also tried it in a Class Library (.Net Framework)

Same error message when using the Package Manager Console command

Install-Package Microsoft.EntityFrameworkCore.Tools.DotNet

I tried editing the csproj file directly and adding

     Version="1.0.0" />

but dotnet ef still gives the same error message and nuget package manager doesn't see it

I tried to create a new dot net core class library but even a blank one refuses to install the tools

I have run dotnet restore multiple times and restarted visual studio.

I have downloaded the latest dot net SDK 1.0.4 and run repair to reinstall it. This allows nuget package to install but despite but whatever I do I cannot get the class library to understand dotnet ef

7/4/2017 9:43:06 AM

Accepted Answer

My project targets the full .NET framework, so I can only use the PowerShell commands e.g. add-migration, update-database and not the dotnet ef commands

7/4/2017 1:35:15 PM

Popular Answer

Microsoft.EntityFrameworkCore.Tools.DotNet needs to be added to you class library by editing the project. That is the only way adding it is supported right now. Right click the project and select Edit *.csproj. Then, add the following:

    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0-preview2-final" />

Note: the version is the latest at the time of this post and will likely change in the future.

I have a more in-depth solution here: EF 7 Migrations with multiple DBContexts

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow