My .NET Core class library provides a model for my database and my WPF application needs to reference this class library in order to access the database. Is it possible to add a reference from the WPF application to the class library and use this model?
I use Entity Framework Core to access the database and my model is generated by EF Core tool.
You have got a class library for .NET Core 3.1 using Microsoft.EntityFrameworkCore
and a .NET Framework 4.7.2 application that shall reference this library. There are different options that differ in effort and limitations.
Since .NET Core 3.0, WPF is supported for Windows applications. That means you can migrate your application to .NET Core 3.1 and directly consume your library project. There are lots of tutorials out there, see MSDN for reference. Potential issues for migration include the following aspects.
Usually for small projects migration should be easy and straight-forward, so you can give it a try. If it does not work out for you or you run into issues, the .NET Standard approach might be more convenient for you.
An alternative is to migrate your .NET Core library to .NET Standard. To share the library between both frameworks, you can at most target .NET Standard 2.0, because .NET Framework does not support anything beyond that. Fortunately, the Microsoft.EntityFrameworkCore
library complies with this requirement. However, there are also potential blockers.
If you can migrate .NET Standard and want to support both .NET Framework and .NET Core this is the way to make your library reusable and easily maintainable. In fact, if your dependencies and your code comply with .NET Standard 2.0 migration will almost take no effort.
For the sake of completeness, there is also the option to multi-target your library or the application project. In this process there are two versions of the corresponding project, one for each framework. However, in your case there is no need to do that and you will not benefit from the effort put in.