Understanding one-to-one relationships
A one-to-one relationship means that one entity has a relationship with only one entity of another type. For example, a bicycle requires one lock, which can only be used for that particular bicycle. Similarly, a person is only allowed to possess one driver’s license, which is designated for their use only. In our sample code, a Contact entity has only one Address entity, and an Address entity belongs to only one Contact entity. In the previous section, you learned how to configure a one-to-many relationship using the HasOne()/WithMany() and HasMany()/WithOne() methods. In this section, you will learn how to configure a one-to-one relationship using the HasOne() and WithOne() methods.
One-to-one configuration
In a one-to-one relationship, both sides have a reference navigation property. Technically, both sides have equal positions. However, to explicitly configure the relationship, we need to specify which side is the dependent side...