liveBook · Manning

Code-first approach

A code-first approach defines a system, model, or contract in source code before deriving or finalizing its schema or specification.

How 4 Manning books explain it

Building Web APIs with ASP.NET Core

Code-first is a development approach that defines a data model in application code and derives or updates a database schema from it.

How it is used
Uses C# entities as the starting point for a board-game API’s database schema.
How deep it goes
Walks through entity configuration, initial migration creation, database update, and verification without detailing generated SQL.
Examples
Models board games, domains, mechanics, and relationship entities, then generates and applies an initial migration.
What you can do after
Build it from scratch using EF Core entities and migrations to create and update a database schema.

Read how Building Web APIs with ASP.NET Core explains code-first approach →

.NET in Action, Second Edition

A code-first schema is a database schema generated from application entity definitions and ORM configuration.

How it is used
Uses application entities and EF Core configuration to generate a database schema instead of starting from an existing schema.
How deep it goes
Works through entities, a DbContext, saving, querying, and relationship conventions; does not work through migration commands.
Examples
Builds a book catalog with an in-memory database, then adds ratings and illustrates a many-to-many tag relationship.
What you can do after
Build it from scratch with EF Core entities, a DbContext, and an in-memory provider, then save and query records.

Read how .NET in Action, Second Edition explains code-first approach →

Automating API Delivery

An API development practice that implements an API in code from business requirements and generates its API definition afterward.

How it is used
Generates an API definition and consumer artifacts after implementing API behavior in application code.
How deep it goes
Describes the workflow, generated-definition review, source-of-truth comparison, and exploratory prototyping, but gives no tool commands.
Examples
Uses generated OpenAPI definitions, schemas, examples, client SDKs, API references, and exploratory API prototypes.
What you can do after
Apply it by implementing API changes, generating an OpenAPI definition, checking its consumer-facing quality, and producing downstream artifacts.

Read how Automating API Delivery explains code-first approach →

The Design of Web APIs, Second Edition

A code-first approach is an API development method in which implementation code is authored before the API specification is generated or finalized.

How it is used
Uses implementation code to generate OpenAPI while developing or retro-documenting REST APIs.
How deep it goes
Explains controllers, data models, annotations, monitoring, and trade-offs, but stops short of detailed generation configuration.
Examples
Uses controllers, data models, framework annotations, generated OpenAPI documents, and a /products resource path.
What you can do after
Evaluate when to generate OpenAPI from code, apply annotations or libraries, and recognize documentation and coupling risks.

Read how The Design of Web APIs, Second Edition explains code-first approach →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.