简体   繁体   中英

Can't install "Microsoft.EntityFrameworkCore.Tools.Dotnet" in ASP.NET Core

I have a Class Library named DataLayer and wanted to install some nuget packages to it.

I have successfully installed the packages below:

  • Microsoft.EntityFrameworkCore (version 5.0.8)
  • Microsoft.EntityFrameworkCore.SqlServer (version 5.0.8)

When I try to install the following package, however:

  • Microsoft.EntityFrameworkCore.Tools.Dotnet (version 2.0.3)

I get this error :

Severity Code Description Project File Line Suppression State Error Package 'Microsoft.EntityFrameworkCore.Tools.DotNet 2.0.3' has a package type 'DotnetCliTool' that is not supported by project 'DataLayer'.

I've restarted Visual Studio several times and also deleted my Class Library one time, but the error keeps occurring. Can anyone help me?

Microsoft.EntityFrameworkCore.Tools.DotNet needs to be added to your class library by editing the project. Right-click the project and select Edit *.csproj Then, add the following:

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

You can use Microsoft.EntityFrameworkCore.Tools Package instead of Microsoft.EntityFrameworkCore.Tools.DotNet . When I was new to ef core this was suggested by a Tutorial but later I realized Microsoft.EntityFrameworkCore.Tools works same. Seems like the Microsoft.EntityFrameworkCore.Tools.DotNet is an older version and not working for my project version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM