We just added the Todo model. Now, let's add DBContext to manage and persist Todo in the database. DBContext acts as a bridge between your classes and database. To add it, follow these steps:
- Right-click on the Models folder and navigate to Add | Class:
- Name the class as TodoContext and add the following code snippet to it:
public class TodoContext : DbContext { public TodoContext(DbContextOptions<TodoContext> options) : base(options) { } public DbSet<Todo> Todos { get; set; } }
TodoContext helps you interact with the database and commits the ...