To open a session to the database and query and update instances of your entities, you use a DbContext, which is based on a combination of the unit of work and repository patterns.
Let's see how to prepare the Tic-Tac-Toe application to use Entity Framework Core 2 to connect to an SQL Database by using a DbContext and a connection string:
- Go to the Solution Explorer, add a new folder called Data, add a new class called GameDbContext.cs, and implement a DbSet property for each Model (UserModel, TurnModel, and more):
public class GameDbContext : DbContext { public DbSet<GameInvitationModel> GameInvitationModels { get; set; } public DbSet<GameSessionModel> GameSessionModels { get; set; } public DbSet<TurnModel> TurnModels ...