We could have conventional relationships such as one-to-one, one-to-many, and many-to-many in our entity relationships with ease in EF. Let's explore them in detail in this section. To make it interesting, let's design the database of the blogging system during the course of understanding relationships:
We have seen the proposed design of the blogging system; now let's learn about the relationships and how they could be built using the same design.
We need a new entity to explain the one-to-one relationship, as the existing entities don't have the provision to explain the same. So let's pick the Address
entity from the proposed design and see how the one-to-one relationship is built:
The code illustrating one-to-one relationship between User
and Address
entities was listed as follows:
public class User
{
public int Id { get; set; }
public string DisplayName { get; set; }
public string Username { get; set; }
public string...