0
votes

I have an ASP.NET Core Web API Application, I was instructed to update the NuGet Packages, once I started upgrading, NuGet started throwing errors about missing dependencies, after going one by one (one depends on other that was not installed and that one depends from another 2 that were not installed and so it goes); I encountered the following error where I got stuck:

Detected package downgrade: Microsoft.EntityFrameworkCore.SqlServer from 2.2.6 to 2.2.4. Reference the package directly from the project to select a different version.

Below that error I see that "Install a Reference to Microsoft.EntityFrameworkCore.Abstractions 2.2.6 to solve the issue"

But when I try to do that, it throws:

"Version conflict detected, Install a Reference to Microsoft.EntityFrameworkCore 2.2.6 to solve this issue"

Of course this is a circular error is not giving me options, I tried to install version 2.2.4 and threw the same conflict error (but related to version 2.2.3 and so on).

This is Visual Studio Enterprise 2017, ASP.NET Core 2.1

I already tried adding true To the .cproj file and did not work at all

1

1 Answers

1
votes

I think you've gone down a rabbit hole here. The exception, in general, just means that your project is getting two references for the same package and one of those references is to a lesser version. That could happen for any number of reasons, but it generally boils down to two possibilities (or a combination of the two):

  1. You've got different metapackages that reference the same package, and the metapackage versions are mismatched.

  2. You've got one or more project dependencies, and those dependent project(s) use different versions of the same package/metapackage.

The stuff about "install a reference to Microsoft.EntityFrameworkCore.Abstractions" are usually red herrings. It's calling out the specific package reference version mismatch, but that doesn't mean that literally installing that package is the best approach.

The big thing is going to be metapackages, as these are basically just multiple packages rolled into one reference. The actual underlying packages and their versions are not directly referenced, but they're there, just as if you'd directly added the reference. As such, it's not always clear that two separate metapackages are actually using one or more of the same packages under the hood.

The best course at this point is to rollback your package reference changes. You've probably introduced more problems than you've solved. Remove any extraneous or superfluous references. For example, if you've got a reference to both Microsoft.EntityFrameworkCore and Microsoft.EntityFrameworkCore.Abstractions, remove Abtractions. It's easiest to do this by directly editing the .csproj file. Go project by project in your solution and pare back packages to only the ones absolutely necessary for your project(s). Hint: if you start seeing red squigglies in your code, you actually needed that one.

Once you've done this, upgrade all the NuGet packages for the entire solution all at once. Literally, right-click the solution and choose "Manage NuGet packages for the Solution". You should also check the "Consolidate" tab and ensure that there's nothing there, i.e. you're running the same versions of everything across all projects. Then, you should be good to go.