© Eric Vogel 2021
E. VogelBeginning Entity Framework Core 5https://doi.org/10.1007/978-1-4842-6882-7_4

4. Database Context

Eric Vogel1  
(1)
Okemos, MI, USA
 

In this chapter, I will cover what an Entity Framework Core 5 database context is and how to configure it. The database context implemented in the DbContext class allows you to interface with your database store. Through DbContext, you can perform create, read, update, and delete operations. In addition, you can perform aggregations such as sum, max, average, and count.

Creating a Simple Database Context

To get started, create a class named AppDbContext that inherits from DbContext as seen in Listing 4-1.
using Microsoft.EntityFrameworkCore;
namespace EFCOre5WebApp.DAL
{
    public class AppDbContext ...

Get Beginning Entity Framework Core 5: From Novice to Professional 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.