Configuring Entity Framework Core
Since, as detailed in Chapter 7, Understanding the Different Domains in Software Solutions, database handling is confined within a dedicated application layer, it is good practice to define your Entity Framework Core (DbContext
) in a separate library. Accordingly, we need to define a .NET class library project.
We have two different kinds of library projects: .NET Standard and .NET Core. Please refer to Chapter 5, Implementing Code Reusability in C# 12, for a discussion on the various kinds of libraries.
While .NET libraries are tied to a specific .NET Core version, .NET Standard 2.0 libraries have a wide range of applications since they work with any .NET version greater than 2.0 and also with the old .NET Framework 4.7 and above.
Since our library is not a general-purpose library (it’s just a component of a specific .NET 8 application), instead of choosing a .NET Standard library project, we can simply choose a .NET 8 library...