Is it a good idea to add .Net Framework class library to .Net core console application

.net .net-core .net-framework-version entity-framework-core


I have created a new .net core console application and, I have all my BL and DAL in a NuGet package which is in .net Framework(some class libraries in this are in .Net framework 2.0). if I install this NuGet in .Core library it will not work fine which is obvious.

so the question is, if I add a .Net Framework(4.7) class library and install this Nuget and EFCore in it are there anything that would go wrong? will I be able to consume this class library in .Net core console application.

what I have done so far:

I have added the .net framework class library to solution installed the this NuGet and EF Core, I don't see any error in the class library.

3/16/2020 8:26:36 AM

Accepted Answer

No, it's a bad idea and it won't work.

Any .NET Framework compiled libraries can't be used and referenced in .NET Core projects and vice versa.

You can do it with NuGet packages, but it would be a good idea to reduce the risk of failure by converting the code to .NET Standard. Because then you can use safely in .NET Core as long as your .NET Framework class library doesn't contain non-.NET Standard namespaces and classes.

See this official .NET Standard compatibility references:

Also you can check manually the API compatibility by going to this:

UPDATE 1: Thanks to Jon Skeet's comment, looks like there is a way to reference .NET Framework into .NET Core by using nuget packages targeting .NET Framework!


But there's still a chance that it might not work, especially if the third party libraries uses classes that only available in .NET Framework that's not ported to .NET Core such as Workflow Foundation and server-side WCF.

I'm not going to delete my answer, because I have to keep my answer as a lesson for me as well :)

UPDATE 2: reword to update from only way to doable with NuGet package reference as suggested by Jon.

3/16/2020 10:21:43 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow