One-to-One association

One-to-one associations are the simplest kind of associations. They usually correspond to the foreign key relations when the foreign key column is the primary key column.

The database contains the Person and Contact tables, between which there is a foreign key created against the primary key fields of these tables.

Tables for creating a one-to-one association

We perform the following sequence of operations:

  • create an Entity Framework Core model;

  • add the Person and Contact tables to the model.

As a result, we have the following model:

A created model

The association between the Person and the Contact entities looks as follows:

A created association

See also

Overview

One-to-Many association

Working with associations