The Has/With Pattern For Configuring Relationships

When configuring relationships with the Fluent API, you will use the Has/With pattern. The Has side of the pattern is represented by the HasOne and HasMany methods. The With side of the relationship is represented by the WithOne and WithMany methods.

The HasOne method is used for reference navigation properties as is the WithOne method. The HasMany and WithMany methods are used for collection navigation properties.

A Has* method must be combined with a With* method to configure a valid relationship.

Last updated: 27/02/2018 13:23:19

© 2018 - Learn Entity Framework Core.
All rights reserved.