I am trying to install some packages in my API using :
Install-Package Microsoft.EntityFrameworkCore.SqlServer
It throws an error (Given below):
NU1608: Detected package version outside of dependency constraint: Microsoft.AspNetCore.App 2.1.1 requires Microsoft.EntityFrameworkCore.SqlServer (>= 2.1.1 && < 2.2.0) but version Microsoft.EntityFrameworkCore.SqlServer 2.2.0 was resolved.
Install-Package : NU1107: Version conflict detected for
Microsoft.EntityFrameworkCore. Install/reference Microsoft.EntityFrameworkCore
2.2.0 directly to project ChinookCoreAPI to resolve this issue.
ChinookCoreAPI -> Microsoft.EntityFrameworkCore.SqlServer 2.2.0 ->
Microsoft.EntityFrameworkCore.Relational 2.2.0 ->
Microsoft.EntityFrameworkCore (>= 2.2.0)
ChinookCoreAPI -> Microsoft.AspNetCore.App 2.1.1 ->
Microsoft.EntityFrameworkCore (>= 2.1.1 && < 2.2.0).
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore.SqlServer
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManag
ement.PowerShellCmdlets.InstallPackageCommand
Install-Package : Package restore failed. Rolling back package changes for
'ChinookCoreAPI'.
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore.SqlServer
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManag
ement.PowerShellCmdlets.InstallPackageCommand
Can someone help me solve this?
EF Core and ASP.NET Core used to be shipped together. But starting in ASP.NET Core 2.x (Microsoft.AspNetCore.App
/Microsoft.AspNetCore.App
meta packages), EF Core is now part of the ASP.NET Core meta packages. See Microsoft.AspNetCore.App metapackage for ASP.NET Core 2.1.
Then in ASP.NET Core 3.0, EntityFrameworkCore, JSON.NET and Microsoft.CodeAnalysis won't be a part of the Microsoft.AspNetCore.App/All
packages anymore.
See GitHub announcement.
You are getting this issue, because Install-Package Microsoft.EntityFrameworkCore.SqlServer
is installing the latest version of EF Core (2.2) while your ASP.NET Core application is still at 2.1.
One option is to upgrade your application to ASP.NET Core 2.2.
But the issue here seems that ChinookCoreAPI
requires the older version of ASP.NET Core (and EF Core), namely 2.1. From your question its not clear if you did the Install-Package Microsoft.EntityFrameworkCore.SqlServer
on your application project or on ChinookCoreAPI
.
If its on Install-Package Microsoft.EntityFrameworkCore.SqlServer
installing the newest EF Core on the App project should fix it. Otherwise lower the verison of ChinookCoreAPI
to 2.1.1
Your Current Version of ASPNET Core (Microsoft.AspNetCore.App 2.1.1) does not support latest Version of EFCore (Microsoft.EntityFrameworkCore 2.2.0).
In Startup.cs, Decrease the EF Version, as "Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.1" And Restore again.
This worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With