Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot add EntityFrameworkCore Tools to class library in Visual Studio 2017

I created a new Class Library (.Net Core) and wanted to add the package Microsoft.EntityFrameworkCore.Tools.DotNet 1.0.0. 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.0' 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

like image 884
dfmetro Avatar asked Mar 09 '23 16:03

dfmetro


1 Answers

CLI tool packages cannot be added as standard package references. You need something like this in your csproj file:

<ItemGroup>
<DotNetCliToolReference 
    Include="Microsoft.EntityFrameworkCore.Tools.DotNet" 
    Version="1.0.0" />
</ItemGroup>

This is a bug/limitation in NuGet. See https://github.com/NuGet/Home/issues/4190 for more details.

like image 126
divega Avatar answered Mar 12 '23 06:03

divega