liveBook · Manning

Convention over configuration

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

Convention over configuration is a design approach in which framework-defined naming and structure conventions determine behavior unless explicitly overridden.

Convention over configuration lets framework-defined names and structures determine behavior by default, so application code can stay focused on its domain model. EF Core supports plain C# entity classes without requiring a framework base class or mapping attributes. It discovers database mappings from conventions and allows explicit customization when the defaults do not fit. section 12.2.2

EF Core discovers keys and relationships

A Recipe class with a RecipeId property follows EF Core's primary-key convention. An Ingredient class with IngredientId and RecipeId, together with Recipe.Ingredients, lets EF Core infer a foreign-key relationship in which one recipe has many ingredients. No mapping attributes appear in the model. section 12.2.2

The same preference appears when choosing ASP.NET Core API styles. Web API controllers rely on MVC conventions, reflection, controller discovery, and a complex filter pipeline. Minimal APIs offer a simpler, more explicit approach, so convention preference becomes one factor in the choice alongside performance, filtering, and content negotiation. section 20.6

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

How deep it goes
Explains default entity discovery, keys, foreign keys, and relationships, but defers most naming and column conventions.
Examples
Uses Recipe and Ingredient classes, a RecipeId key convention, an Ingredient RecipeId foreign key, and API-style comparison criteria.
What it assumes
Assumes basic C# classes and properties while defining primary keys, foreign keys, and many-to-one relationships.
What you can do after
Evaluate EF Core entity shapes and choose between minimal APIs and web API controllers using convention preference and technical needs.
How it connects
Connects entity models with primary keys, foreign keys, relationships, reflection, MVC, and API design.

Also explained in

Compare how 2 books explain convention over configuration →

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.