This documentation is archived and is not being maintained.

End Element (CSDL)

The End element in conceptual schema definition language (CSDL) can be a child of the Association element or the AssociationSet element. In each case, the role of the End element is different and the applicable attributes are different.

End Element as a Child of the Association Element

An End element (as a child of the Association element) identifies the entity type on one end of an association and the number of entity type instances that can exist at that end of an association. Association ends are defined as part of an association; an association must have exactly two association ends. Entity type instances at one end of an association can be accessed through navigation properties or foreign keys if they are exposed on an entity type. For more information, see NavigationProperty element, ReferentialConstraint element, and Defining and Managing Relationships.

An End element can have the following child elements (in the order listed):

Applicable Attributes

The following table describes the attributes that can be applied to the End element when it is the child of an Association element.

Attribute Name Is Required Value

Type

Yes

The name of the entity type at one end of the association.

Role

No

A name for the association end. If no name is provided, the name of the entity type on the association end will be used.

Multiplicity

Yes

1, 0..1, or * depending on the number of entity type instances that can be at the end of the association.

  • 1 indicates that exactly one entity type instance exists at the association end.

  • 0..1 indicates that zero or one entity type instances exist at the association end.

  • * indicates that zero, one, or more entity type instances exist at the association end.

Bb896235.note(en-us,VS.100).gifNote:
Any number of annotation attributes (custom XML attributes) may be applied to the End element. However, custom attributes may not belong to any XML namespace that is reserved for CSDL. The fully-qualified names for any two custom attributes cannot be the same.

Example

The following example shows an Association element that defines the CustomerOrders association. The Multiplicity values for each End of the association indicate that many Orders can be associated with a Customer, but only one Customer can be associated with an Order. Additionally, the OnDelete element indicates that all Orders that are related to a particular Customer and that have been loaded into the ObjectContext will be deleted if the Customer is deleted.

<Association Name="CustomerOrders">
  <End Type="ExampleModel.Customer" Role="Customer" Multiplicity="1" />
  <End Type="ExampleModel.Order" Role="Order" Multiplicity="*">
        <OnDelete Action="Cascade" />
  </End>
</Association>

End Element as a Child of the AssociationSet Element

The End element specifies one end of an association set. The AssociationSet element must contain two End elements. The information contained in an End element is used in mapping an association set to a data source. For more information, see AssociationSetMapping Element (MSL) and EndProperty Element (MSL).

An End element can have the following child elements (in the order listed):

Bb896235.note(en-us,VS.100).gifNote:
Annotation elements must appear after all other child elements. Annotation elements are only allowed in conceptual models for applications that target the .NET Framework version 4 or later. The XML namespace for such models is http://schemas.microsoft.com/ado/2008/09/edm.

Applicable Attributes

The following table describes the attributes that can be applied to the End element when it is the child of an AssociationSet element.

Attribute Name Is Required Value

EntitySet

Yes

The name of the EntitySet element that defines one end of the parent AssociationSet element. The EntitySet element must be defined in the same entity container as the parent AssociationSet element.

Role

No

The name of the association set end. If the Role attribute is not used, the name of the association set end will be the name of the entity set.

Bb896235.note(en-us,VS.100).gifNote:
Any number of annotation attributes (custom XML attributes) may be applied to the End element. However, custom attributes may not belong to any XML namespace that is reserved for CSDL. The fully-qualified names for any two custom attributes cannot be the same.

Example

The following example shows an EntityContainer element with two AssociationSet elements, each with two End elements:

<EntityContainer Name="BooksContainer" >
  <EntitySet Name="Books" EntityType="BooksModel.Book" />
  <EntitySet Name="Publishers" EntityType="BooksModel.Publisher" />
  <EntitySet Name="Authors" EntityType="BooksModel.Author" />
  <AssociationSet Name="PublishedBy" Association="BooksModel.PublishedBy">
    <End Role="Book" EntitySet="Books" />
    <End Role="Publisher" EntitySet="Publishers" />
  </AssociationSet>
  <AssociationSet Name="WrittenBy" Association="BooksModel.WrittenBy">
    <End Role="Book" EntitySet="Books" />
    <End Role="Author" EntitySet="Authors" />
  </AssociationSet>
</EntityContainer>

See Also

Show: