liveBook · Manning

Dependent entity

As explained in .NET in Action, Second Edition

A dependent entity is an entity whose existence or identity depends on a principal entity.

A dependent entity cannot exist without its principal entity. In a book catalog, Rating depends on Book, while Book can exist without a rating. EF Core uses navigation properties and foreign-key conventions to map the relationship. section 5.2.3

Listing 5.8 One-to-one relationship with Book as the parent and Rating as the child
class Book {
  public int Id {get;set;}
  public Rating? Rating {get;}
}
class Rating
{
  public int Id {get;set;}
  public int BookId {get;set;}
  public Book Book {get;set}
}

This C# model shows Book as the principal and Rating as the dependent, linked by BookId. section 5.2.3

How .NET in Action, Second Edition covers it

How deep it goes
Explains navigation properties and foreign-key conventions, but notes that code-first schemas do not enforce one-to-one relationships at database level.
Examples
Uses Book and Rating classes, with BookId linking each rating to its book.
What you can do after
Apply EF Core conventions to model a dependent entity and its relationship to a principal.
How it connects
Connects dependent and principal entities through foreign keys, navigation properties, and one-to-one or one-to-many relationships.

Also explained in

Compare how 2 books explain dependent entity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET in Action, Second Edition. The section links point to the parts of the book it draws on.