Reputation: 4425
I have made .net core 2.0 web app. I have added Entity Framework 6.2.0 using NUGET and then I get this error
Package 'EntityFramework 6.2.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
How do I fix this?
Upvotes: 42
Views: 40527
Reputation: 38683
The problem is your entity version is confused with .NetFramework
and .NetCore
. Your application target framework is Asp.Net Core
. So You should install package related with Asp.net Core
In your case 'EntityFramework 6.2.0'
is supports by .NETFramework,Version=v4.6.1'
not by '.NETCoreApp,Version=v2.0'
. So use this below version of entity framework instead of yours.
PM> Install-Package Microsoft.EntityFrameworkCore -Version 2.0.1
If Nuget is not installed this command should do it
dotnet add package Microsoft.EntityFrameworkCore
Upvotes: 53
Reputation: 737
In my case, my project was Core 2.2. I installed (NuGet) Microsoft.EntityFrameworkCore v2.2.4 first and all built fine. Then I ACCIDENTALLY installed Microsoft.AspNet.Identity rather than Microsoft.AspNetCore.Idendity (v2.2.0). Once my eyes spotted the missing 'Core' in the .Identity package and I fixed it by uninstalling the wrong and installing the right, then the warnings went away. I expect I'm not the only one that went a little fast on the Nuget installations on a new project :)
Upvotes: 1
Reputation: 3519
I had the same problem, and was introduced by altering my solution to use a new TargetFramework.
<TargetFramework>netcoreapp2.2</TargetFramework>
After the Update I tried to add the Identity Framework but failed with a warning as described.
By Adding the packages in this sequence solved it for me:
Microsoft.EntityFrameworkCore
Microsoft.AspNetCore.Identity
Upvotes: 0
Reputation: 239
Alternatively you can change your target framework to net461 as below.
<TargetFramework>net461</TargetFramework>
By changing your target framework to net461 makes you available to use .net core and full .net frameworks. I think that for this period of time, this approach is better. Because EF Core still hasn't got some main features like many to many relationship and some others. Sure it depends on your needs and expectations from an ORM tool.
Upvotes: 2
Reputation: 12174
Change your project to .NETFramework,Version=v4.6.1
or choose an Entity Framework nuget that supports .NETCoreApp,Version=v2.0
Upvotes: 0