Configuring Entity Framework Core
Since 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 Core class library project. As we discussed in the Book use case – understanding the main types of .NET Core projects sections of Chapter 2, Non-Functional Requirements, we have two different kinds of library projects: .NET Standard and .NET (Core).
While .NET Core 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 classical .NET Framework 4.7.2 and above.
However, version 5 of the Microsoft.EntityFrameworkCore
package, which is the version that comes with .NET 5, depends just on .NET Standard 2.1. This means that it is not designed to work with a specific .NET (Core) version but that it just...