liveBook · Manning

Data model

As explained in ASP.NET Core in Action, 3e

A database model represents the application data stored in a database and the structure used to work with that data.

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.
CH12_F04_Lock3

Trace how a request loads database data through RecipeService while keeping EF Core out of the endpoint. section 12.2

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains entities, DbContext, providers, dependency injection, and migrations, but defers advanced EF Core customization.
Examples
Uses a recipe API with recipes, ingredients, RecipeService, migrations, and an Identity-enabled ApplicationUser.
What it assumes
Assumes a basic ASP.NET Core application and teaches database integration without requiring a general application build.
What you can do after
Build a small EF Core data model, synchronize its database schema, and isolate data access in services.
How it connects
Connects entities and DbContext with database schema, migrations, dependency injection, service layers, and Identity.

Also explained in

Compare how 23 books explain data model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.