Joshit
Joshit

Reputation: 1325

What to do if MSB3277 occurs in asp net core app

I am using a Database-Project referencing EntityFrameworkCore 2.1.3 package but the AspNetCore.App-metapackage contains EntityFrameworkCore 2.1.2. After bringing in my Database-Project I get this msbuild-warning:

Warning MSB3277 Found conflicts between different versions of "Microsoft.EntityFrameworkCore" that could not be resolved.

I´ve googled around a bit an I found this doc: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/metapackage-app?view=aspnetcore-2.1

I´m using a third-party library (NpgSql for Postgre) which relies on 2.1.3... Should I downgrade all packages, so that they use efcore 2.1.2 package or should I ignore this warning? Or better question: Which way is less painful?

Thanks in advance

Upvotes: 4

Views: 2079

Answers (3)

ilker AYTI
ilker AYTI

Reputation: 1

My problem was the same

"Warning MSB3277 Found conflicts between different versions of "Microsoft.AspNetCore.App" that could not be resolved."

I have developed the project on the computer with .net core sdk 2.2.204. I got this error when I copied the project from GIT to my home computer. When I try VS2017 and VS2019, nothing has changed. The actual problem was the SDK conflict. SDK 2.2.104 is the last stable version for VS2017.

The problem was solved when I upgraded my home computer to the latest current version (2.2.300)

I hope this solution works well for others. I've tried all the other methods.

Upvotes: 0

Shay Rojansky
Shay Rojansky

Reputation: 16722

It's true that Npgsql.EntityFrameworkCore.PostgreSQL is currently at version 2.1.2, and depends on Microsoft.EntityFrameworkCore 2.1.2. However, there shouldn't be any issue with using an older version of the Npgsql EF Core provider with newer patch versions of EF Core itself.

You can probably get rid of this warning by taking a direct dependency on Microsoft.EntityFrameworkCore 2.1.3 in your own project.

Upvotes: 4

poke
poke

Reputation: 388023

The recommended way to reference these packages for such situations is to reference a version-less app metapackage in your web project:

<PackageReference Include="Microsoft.AspNetCore.App" />

And in library projects, you should reference just the minor version with a patch level of 0:

<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" />

When referencing that project, the shared framework will automatically make the EF Core reference roll forward to the current version of the installed .NET Core runtime.

If you cannot downgrade the EF Core reference in that library project, the best solution would probably to upgrade your .NET Core SDK/runtime to 2.1.4, so that you run the latest version which contains EF Core 2.1.3 anyway.

Upvotes: 1

Related Questions