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.

images_Association1toMany-table

We perform the following sequence of operations:

create a Telerik Data Access model;
add the Dept and Emp tables to the model.

As a result, we have the following model:

images_Association1toMany-model-TDA

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

images_Association-Editor-1ToMany-TDA

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.

 

ExpandedToggleIcon        Collection Types

The navigation property in the entity on the one side is a collection of entities from the many side. The type of the collection can be set globally for the model in the Model Settings using the Default collection type parameter or for each navigation property separately in the navigation property properties using the Collection Type property. By default, List collections are used. You can use the following collection for navigation properties:

Default - uses the collection type, specified in the Model Settings globally.
List
ObservableCollection
TrackedList
TrackedBindingList

 

ExpandedToggleIcon        See Also


Send feedback on this topic

© 2008 - 2024 Devart. All rights reserved.