liveBook · Manning

Database-first design

As explained in Building Web APIs with ASP.NET Core

A development workflow that derives application data models or entities from an existing database schema.

Database-first design derives C# entity classes from an existing database schema. The schema remains the source structure, while Entity Framework Core provides the data model used by the application. section 4.3.2 section 4.0

A practical EF Core workflow is:

  • Install the EF Core packages and the dotnet-ef command-line tools. section 4.3.2
  • Reverse-engineer the existing schema into C# entity classes with scaffolding. section 4.3.2
  • Review the generated model and adjust it to application needs while keeping it aligned with database changes. section 4.3.2
> dotnet add package Microsoft.EntityFrameworkCore.SqlServer --version 6.0.11
> dotnet add package Microsoft.EntityFrameworkCore.Design --version 6.0.11

Install the SQL Server provider and EF Core design package before using database modeling features. section 4.3.2

> dotnet tool install --global dotnet-ef --version 6.0.11

Install the versioned dotnet-ef CLI globally, or omit the global switch to keep it project-specific. section 4.3.2

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Defines reverse engineering, tooling, conventions, and model review, but does not show detailed scaffolding output.
Examples
Uses EF Core package commands, dotnet-ef installation, generated C# entities, and model review.
What it assumes
Assumes an existing database schema and a .NET project, while defining the schema–data-model distinction.
What you can do after
Apply it via EF Core scaffolding to create an application data model from an existing relational schema.
How it connects
Connects database schema, data model, EF Core, scaffolding, migrations, code-first, ORM, and DBMS concepts.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.