I am trying to create a new Restful web api using Asp.Net Core 2.1 and I would like to use a shared data library to access the underlying data. The data library uses Entity Framework Core 2.2.4 and entity framework 6.1
There are other applications that reference this data library and it would be beneficial to have the web api also referencing the same project.
As soon as I add any code that references the dbContext I get the following error when trying to compile the web api:
Assembly 'data' with identity 'data uses 'Microsoft.EntityFrameworkCore, Version=126.96.36.199 which has a higher version than referenced assembly 'Microsoft.EntityFrameworkCore' with identity 'Microsoft.EntityFrameworkCore, Version=188.8.131.52, Culture=neutral, PublicKeyToken=adb9793829ddae60'
Is what I'm trying to do even possible and if so can you please point me in the right direction
The version of EF Core is tightly coupled with the version of ASP.NET Core you're using. Basically: EF Core 2.2.x only works on ASP.NET Core 2.2.x. You'll need to update the
netcoreapp2.2 to make it work.
Also, the recommended way to reference ASP.NET Core (in .NET Core 2.x projects) is to not include a specific version:
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />