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 5 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 →

Data-Oriented Programming in Java

A code-first approach is a software development approach that begins by implementing a representation before fully investigating the domain meaning of the data.

How it is used
Uses rapid representation as an entry point for investigating ambiguous domain data.
How deep it goes
Descends from primitive field mapping to explicit domain constraints, but stops before showing their final type-safe encoding.
Examples
Uses JSON and Java records to model drying-oil measurements, then documents elapsed-day and contact-angle constraints.
What you can do after
Evaluate representations by questioning field meanings and recording domain constraints before treating primitive mappings as final.

Read how Data-Oriented Programming in Java 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
Generates an OpenAPI description from implementation code during API design or when documenting an existing API.
How deep it goes
Defines the approach and compares alignment, framework limits, production changes, and stack choice without detailing a generation procedure.
Examples
Uses framework-generated OpenAPI and adding a library to document an existing API’s operations, inputs, and successful outputs.
What you can do after
Evaluate whether implementation-generated OpenAPI fits a team's skills, framework, deployment habits, and need for an independent API description.

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

Also covered in

What to know first

Related concepts

Questions about code-first approach

What is code-first approach?

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

Which Manning books explain code-first approach?

Building Web APIs with ASP.NET Core, .NET in Action, Second Edition, Data-Oriented Programming in Java, Automating API Delivery and The Design of Web APIs, Second Edition.

What should I know before learning code-first approach?

Manning books that teach code-first approach usually introduce data model, OpenAPI specification and SQL first.

What is the difference between code-first approach and design-first approach?

A code-first approach defines a system, model, or contract in source code before deriving or finalizing its schema or specification. A specification-first approach defines and validates an interface or behavioral contract before implementing the system that conforms to it.

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.