Delen via


AssociationSet Element (CSDL)

The AssociationSet element in conceptual schema definition language (CSDL) is a logical container for association instances of the same type. An association set provides a definition for grouping association instances so that they can be mapped to a data source. For more information about mapping, see AssociationSetMapping Element (MSL).

The AssociationSet element can have the following child elements (in the order listed):

The Association attribute specifies the type of association that an association set contains. The entity sets that make up the ends of an association set are specified with exactly two child End elements.

Applicable Attributes

The table below describes the attributes that can be applied to the AssociationSet element.

Attribute Name Is Required Value

Name

Yes

The name of the entity set. The value of the Name attribute cannot be the same as the value of the Association attribute.

Association

Yes

The fully-qualified name of the association that the association set contains instances of. The association must be in the same namespace as the association set.

Note

Any number of annotation attributes (custom XML attributes) may be applied to the AssociationSet 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:

<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

Concepts

Entity Framework Overview
CSDL Specification
EntityContainer Element (CSDL)

Other Resources

CSDL, SSDL, and MSL Specifications
ADO.NET Entity Data Model Tools
association set (Entity Data Model)
association set end (Entity Data Model)