8 Configuring relationships

This chapter covers

  • Configuring relationships with By Convention
  • Configuring relationships with Data Annotations
  • Configuring relationships with the Fluent API
  • Mapping entities to database tables in five other ways

Chapter 7 described how to configure scalar (nonrelational) properties. This chapter covers how to configure database relationships. I assume that you’ve read at least the first part of chapter 7, because configuring relationships uses the same three approaches—By Convention, Data Annotations, and the Fluent API—to map the database relationships.

This chapter covers how EF Core finds and configures relationships between entity classes, with pointers and examples showing how to configure each type of relationship: ...

Get Entity Framework Core in Action, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.