A data model represents application data and the structure used to work with it. In Entity Framework Core, it consists of entities and a DbContext that describe the data your ASP.NET Core application stores and loads. section 12.0 section 12.2
Build a data model by:
- Choosing a database provider such as SQLite, Postgres, or SQL Server. section 12.2
- Defining entities and the application's DbContext. section 12.2
- Registering the DbContext with dependency injection and generating migrations. section 12.2 section 12.3
- Applying migrations so the database schema matches the model. section 12.3
Recipe application
A simple recipe API can model recipes and ingredients, expose them through a DbContext, and keep database access inside RecipeService rather than endpoint handlers. When the model changes, a migration records additions such as new entities or columns and updates the schema. section 12.2 section 12.3 section 12.4
Figure 12.4 Handling a request by loading data from a database using EF Core. Interaction with EF Core is restricted to RecipeService; the endpoint doesn’t access EF Core directly.
Trace how a request loads database data through RecipeService while keeping EF Core out of the endpoint. section 12.2






















