One-to-Many association

The following example illustrates creation of a one-to-many association within an Entity Framework model.

The database contains the Dept and Emp tables, which have a foreign key constraint between them.

The field DEPTNO in the table Emp receives the ID value of the associated record in the Dept table.

Association 1:N table

We perform the following sequence of operations:

  • create an Entity Framework model;
  • add the Dept and Emp tables to the model.

As a result, we have the following model:

Association 1:N model

The association between the Dept and the Emp entities looks as follows:

Association Editor 1:N

In case all foreign key columns of the details table are nullable, the association will have the zero-or-one to many type, which means that the detail class navigation property referring to the master class can be NULL.

See also

  • Overview
  • One-to-One association
  • Many-to-Many association