Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Version Conflict detected for Microsoft.EntityFrameworkCore.Install

I am getting the following error when adding an asp.net core api to an existing project I am working on.

"Version Conflict detected for Microsoft.EntityFrameworkCore.Install/reference Microsoft.EntityFrameworkCore 2.2.1 directly to project to resolve this issue"

I tried to add the Nuget package but get further version conflicts across a number of different packages and the process always fails. At first I thought this may be an issue with my project so I started a new solution from scratch and managed to replicate the issue with a few simple steps.

  1. Create a new solution (EFDemo)
  2. Add a new .net Core class library to the solution called EFDemo.BL
  3. Add the following Nuget packages to project EFDemo.BL (as I'm using an existing database for my new project)
  4. Microsoft.EntityFrameworkCore.SqlServer (v2.2.1)
  5. Microsoft.EntityFraneworkCore.Tools (v2.2.1)
  6. Add a new .net core web application called EFDemo.Api and select the API project template.
  7. Add a reference from EFDemo.BL to EFDemo.Api.
  8. Build and see the failure.

I have reviewed the following post but its solution does not work for me as I have no reference to "Microsoft.EntityFrameworkCore" in any of my csproj files. Version conflict detected for NuGet packages.

I have also reinstalled .net SDK, rebooted a million times and still can't understand what the issue is.

like image 661
user1474992 Avatar asked Jan 23 '19 08:01

user1474992


People also ask

What is Microsoft EntityFrameworkCore tools for?

A plugin for Microsoft. EntityFrameworkCore to support repository, unit of work patterns, and multiple databases with distributed transaction supported. For EF Core: 2, 3.

What is Microsoft EntityFrameworkCore design?

Microsoft. EntityFrameworkCore. Design contains all the design-time logic for Entity Framework Core. It's the code that all of the various tools (PMC cmdlets like Add-Migration , dotnet ef & ef.exe ) call into. If you don't use Migrations or Reverse Engineering, you don't need it.


2 Answers

I have encountered the same error recently.

What I have done to sort this out:

Installed .Net Core 2.2 SDK

Then in my project I have changed in all .csproj files:

  <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>

whereas before it was:

      <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>

This helped straight away and the error dissapeared.

like image 144
Paul de Champignon Avatar answered Sep 21 '22 13:09

Paul de Champignon


The answer to this is quite difficult to catalog because I made many changes while trying to figure this out. In the end, I believe the following steps fixed my issue:

  • Upgrade VS to the latest version (v15.9.3)
  • Uninstall both .Net Core 2.1 and 2.2 SDKs (my project was using 2.1 at the time)
  • Install .Net Core 2.2 SDK
  • Convert all projects in my solution to use .Net Core 2.2 (A pain. I wish there was a Retarget All function!)
  • Reboot, Clean, Build and it works. Phew.

Now to do some work instead of fighting with my tools!

like image 33
user1474992 Avatar answered Sep 18 '22 13:09

user1474992