Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detected package version outside of dependency constraint :Microsoft.AspNetCore.App 2.1.1

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?

like image 707
RAMAN BHATIA Avatar asked Dec 15 '18 11:12

RAMAN BHATIA


2 Answers

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

like image 152
Tseng Avatar answered Nov 18 '22 13:11

Tseng


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.

like image 30
Devesh Sharma Avatar answered Nov 18 '22 13:11

Devesh Sharma