0
votes

I've got a .Net Core 3.1 created in Visual Studio 2019 (C# .Net Core library). I'm attempting to add EntityFrameworkCore thru NuGet package manager to the project. When attempting to add I got some compatibility errors.

So we created the projects and added EntityFrameworkCore on a different system. When attempting to build those project in Visual Studio 2019 on my system, I get the following errors:

Errors in Visual Studio 2019

This is a snapshot of the .Net and .NetCore runtime and sdks installed on the machine: Installed runtime and SDKs

Here are the results from dotnet restore: (Partial Listing)

Foo.WPFApp>dotnet restore Determining projects to restore... : warning NU1701: Package 'System.ComponentModel.Annotations 5.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project. [Foo.WPFApp\Bar.WPFApp.sln] : error NU1202: Package Microsoft.EntityFrameworkCore 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.EntityFrameworkCore 5.0.0 does not support any target frameworks. [Foo.WPFApp\Bar.WPFApp.sln] : error NU1202: Package Microsoft.EntityFrameworkCore.Abstractions 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.EntityFrameworkCore.Abstractions 5.0.0 does not support any target frameworks. [Foo.WPFApp\Bar.WPFApp.sln] : error NU1202: Package Microsoft.Extensions.Caching.Memory 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.Extensions.Caching.Memory 5.0.0 does not support any target frameworks. [Foo.WPFApp\Bar.WPFApp.sln] : error NU1202: Package Microsoft.Extensions.DependencyInjection 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.Extensions.DependencyInjection 5.0.0 does not support any target frameworks. [Foo.WPFApp\Bar.WPFApp.sln] : error NU1202: Package Microsoft.Extensions.Logging 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.Extensions.Logging 5.0.0 does not support any target frameworks. [Foo.WPFApp\Bar.WPFApp.sln] : error NU1202: Package

Here are the results from a dotnet build: (Partial Listing)

Determining projects to restore... ....csproj : warning NU1701: Package 'System.ComponentModel.Annotations 5.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project. [Foo.WPFApp\Bar.WPFApp.sln] ....csproj : error NU1202: Package Microsoft.EntityFrameworkCore 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.EntityFrameworkCore 5.0.0 does not support any target frameworks. [Foo.WPFApp\Bar.WPFApp.sln] ....csproj : error NU1202: Package Microsoft.EntityFrameworkCore.Abstractions 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.EntityFrameworkCore.Abstractions 5.0.0 does not support any target frameworks. [Foo.WPFApp\Bar.WPFApp.sln] ....csproj : error NU1202: Package Microsoft.Extensions.Caching.Memory 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.Extensions.Caching.Memory 5.0.0 does not support any target frameworks. [Foo.WPFApp\Bar.WPFApp.sln] ....csproj : error NU1202: Package Microsoft.Extensions.DependencyInjection 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.Extensions.DependencyInjection 5.0.0 does not support any target frameworks. [Foo.WPFApp\Bar.WPFApp.sln] ....csproj : error

Can someone help me identify the issue and fix it?

2

2 Answers

2
votes

1) Try to clean nuget caches first or just delete all cache files under C:\Users\xxx(current user)\.nuget\packages.

2) disable any installed vs third party extensions under Extensions-->Manage Extensions-->Installed

Or use devenv /safemode to start a initial vs to test whether the issue happens again.

Also, please do not forget to delete every bin and obj folder before you install the nuget package.

If your VS2019 version is not 16.8.X, please update it because NET5.0 is applied since 16.8.

Besides, try to create a new net core app and then test whether the issue happens again.

1
votes

I removed my previous answer since it was not valid.

This is compiled in Visual Studio 2019. It worked on 1 machine. When we brought solution over to another machine it did not work. Packages: EntityFrameworkCore, .SQL, and .Tools

Try cleaning bin/ and obj/ folders before recompiling the project in the machine where it's failing.

Try as well to compile it using dotnet build directly from the command line as well.