I have .NET Core console app that references a data layer project in the same solution, and I have met with an error that I cannot resolve.
Job
is .NET Core 2.0.
Project
is .NET Framework 4.8.
Join Stack Overflow to learn, share knowledge, and build your career.
I have .NET Core console app that references a data layer project in the same solution, and I have met with an error that I cannot resolve.
Job
is .NET Core 2.0.
Project
is .NET Framework 4.8.
You need to have your data library target .NET Standard 2.0 instead of .NET Framework 4.8.
.NET Core and the .NET Framework are different frameworks.
You cannot reference a .NET Framework library from .NET Core, as this diagram from Microsoft illustrates:
To resolve this, Microsoft introduced .NET Standard for class libraries:
.NET Core 2.0 and higher, and .NET Framework 4.6.1 (but preferably higher) can both reference libraries which target .NET Standard 2.0 and lower - see implementation support on the .NET Standard documentation.
You need to re-target your library to .NET Standard 2.0. If any APIs are missing in .NET Standard which your library needs they may be available as NuGet packages instead - you can look these up on apisof.net.
Note that if you're using LINQ to SQL in your data library you're out of luck as that is full .NET only and not available to .NET Standard or .NET Core projects.
The above diagrams were sourced from Introducing .NET Standard