JDBennett
JDBennett

Reputation: 1505

Entity Framework Core not compatible DotNet Core class library

Admittedly still very new to the DotNet core ecosystem.

I have a solution set-up with several class libraries for a framework I am porting over to DotNet core.

I have them targeting Core 2.1 (netcoreapp2.1).

I have Microsoft.EntityFrameworkCore package installed (v2.2) via NuGet.

Locally everything builds and runs fine.

The build definition (Azure DevOps) is failing because NuGet won't pull the EntityFrameworkCore package. Specifically:

Package Microsoft.EntityFrameworkCore 2.2.2 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Microsoft.EntityFrameworkCore 2.2.2 supports: netstandard2.0 (.NETStandard,Version=v2.0) One or more packages are incompatible with .NETCoreApp,Version=v2.1. 

The answer seems obvious - but I am confused on this. DotNet core supports NET Standard 2.0.

Also - I don't get this problem at all locally.

Making it even more confusing - the build actually succeeds if I ignore the NuGet error.

Is there something I need to be doing to make sure the projects explicitly state they are targeting netstandard2.0 in addition to a netcoreapp2.1?

Here is one of the offending project files.

<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
  <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ACME.Framework.Common\ACME.Framework.Common.csproj" />
  <ProjectReference Include="..\ACME.Framework.Entity\ACME.Framework.Entity.csproj" />
</ItemGroup>

</Project>

Update -

I upgraded to DotNet Core 2.2. Still getting this problem.

enter image description here

Upvotes: 0

Views: 4059

Answers (1)

JDBennett
JDBennett

Reputation: 1505

Got it figured out.

My build definition has 3 tasks (NuGet restore, DotNet build, MS Test).

The NuGet restore was failing. I was able to replicate it by downloading the same CLI version of NuGet that Azure Dev Ops was using (v4.1.0) as of today.

Running NuGet restore - I get the same error.

Changing the task to a dotnet restore eliminates this problem.

I would like to understand what dotnet restore is doing under the hood differently that NuGet is doing.

Upvotes: 3

Related Questions