To interact with data as objects/entity classes, EF uses the
Microsoft.EntityFrameworkCore.DbContext class also called
DbContext or simply
Context. This class is in charge of all the entity objects during execution, including populating them with data from the database, keeping track of changes, and persisting them to the database during CRUD operations.
We can easily create our very own
DbContext class for our project, which we will call
ApplicationDbContext, by performing the following tasks:
Right-click on the
/OpenGameList/Data folder and add a new
ApplicationDbContext.cs class. Fill it up with the following code:
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; ...