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 DbSet property that will allow us to query and persist the entity. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.37.20