The DbContext

EF Core configures the model and interacts with the database through a class that derives from the Microsoft.EntityFrameworkCore.DbContext base class.

The DbContext base class builds your model based on the entities you include in it, either by defining properties of the DbSet<TEntity> type, or another entity if is being used by an already included entity.

Here is how the GiveNTake DbContext looks:

public class GiveNTakeContext : DbContext{    ...    public DbSet<Product> Products { get; set; }    public DbSet<Message> Messages { get; set; }    public DbSet<Category> Categories { get; set; }    public DbSet<City> Cities { get; set; }    public DbSet<User> Users { get; set; }        ...}

For each entity we wish to include in our model, we added a

Get Hands-On Full-Stack Web Development with ASP.NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.