Partager via


2.1.39 Containment NavigationProperty

Containment is specified by using a containment NavigationProperty element. A containment NavigationProperty is a NavigationProperty that has a ContainsTarget attribute set to "true".

The EntityType that declares the NavigationProperty is the container EntityType.

The AssociationType that is specified in the containment NavigationProperty is the containment AssociationType.

The EntityType that is specified on the End element of the containment AssociationType, with the Name that is specified by the containment NavigationProperty element's ToRole attribute, is the contained EntityType.

When the instances of both the contained entity and the container entity reside in the same EntitySet, it is called recursive containment.

It MUST NOT be possible for an EntityType to contain itself by following more than one containment NavigationProperty.

The contained EntityType can have a NavigationProperty that navigates to the container EntityType via the containment AssociationType.

The End of the containment AssociationType that is specified by the ToRole attribute of the containment NavigationProperty can have any multiplicity.

For nonrecursive containment, the End of the containment AssociationType that is specified by the FromRole attribute of the containment NavigationProperty MUST have a multiplicity of '1'.

For recursive containment, the End of the containment AssociationType that is specified by the FromRole attribute of the containment NavigationProperty MUST have a multiplicity of '0..1'. The End that is specified by the ToRole cannot have a multiplicity of '1' because this would lead to endless recursion.

An AssociationSet has to have the same EntitySet on both ends if it is for a containment AssociationType that has either the same EntityType on both ends or an EntityType on one end that derives from the EntityType on the other end.

An EntitySet cannot be bound by AssociationSet to more than one AssociationType via a containment NavigationProperty that indicates that the EntityType (or derived EntityTypes) of that EntitySet is contained.

Note Because the EntityType of an EntitySet on an AssociationSet End has to be the same as or derived from the EntityTypes on the corresponding AssociationType End, the EntitySet MUST be either completely contained or completely noncontained.