O'Reilly logo

Code-First Development with Entity Framework by Sergey Barskiy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining relationships

Now let's take a look at relationships between classes, and consequently between tables. There are three main types of relationships in database theory:

  • One-to-Many
  • One-to-One
  • Many-to-Many

First of all, let's define what a relationship is. It is defined based on how two or more objects relate to each other. It is identified by the multiplicity value on both ends of the relationship. For example, One-to-Many means that on one end of a relationship, sometimes called the parent, we only have one entity. On the other end of the relationship, we can have multiple entities, sometimes called children. The Entity Framework API refers to those ends as principal and dependent, respectively. The One-to-Many relationship has a slight variation, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required