concept dependent entity in category entity framework

appears as: dependent entity, dependent entities, dependent entities, dependent entity, The dependent entities
Entity Framework Core in Action

This is an excerpt from Manning's book Entity Framework Core in Action.

  • Dependent entity—Contains the foreign key property(s) that refers to the principal entity
  • Figure 7.1 The Book and Review entity classes show six of the terms used in this chapter to discuss relationships: principal entity, dependent entity, principal key, navigational property, foreign key, and required relationship. Not shown is the optional relationship, which is described in section 2.4.4.

    c07_01.png

    Figure 7.5 shows the three options for building this sort of one-to-one relationship. The principal entities are at the top of the diagram, and the dependent entities are at the bottom. Note that option 1 has the Attendee as the dependent entity, whereas options 2 and 3 have the Ticket at the dependent entity.

    Listing 7.7 Changing the default OnDelete action on a dependent entity
    public static void Configure
        (this EntityTypeBuilder<LineItem> entity)
    {
        entity.HasOne(p => p.ChosenBook)
            .WithMany()
            .OnDelete(DeleteBehavior.Restrict);    #1  
    }
    
    #1   Adds the OnDelete method onto the end of defining a relationship. Setting it to Restrict stops the LineItem from being deleted, hence EF Core will throw an exception if a Book entity class is deleted and a LineItem is linked to that specific book.