Share via


AssociationSet Element (SSDL)

The AssociationSet element in store schema definition language (SSDL) represents a foreign key constraint between two tables in the underlying database. The table columns that participate in the foreign key constraint are specified in an Association element. The Association element that corresponds to a given AssociationSet element is specified in the Association attribute of the AssociationSet element.

SSDL association sets are mapped to CSDL association sets by an AssociationSetMapping element. However, if the CSDL association for a given CSDL association set is defined by using a ReferentialConstraint element, no corresponding AssociationSetMapping element is necessary. In this case, if an AssociationSetMapping element is present, the mappings it defines will be overridden by the ReferentialConstraint element.

The AssociationSet 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 AssociationSet element.

Attribute Name Is Required Value

Name

Yes

The name of the foreign key constraint that the association set represents.

Association

Yes

The name of the association that defines the columns that participate in the foreign key constraint.

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 SSDL. The fully-qualified names for any two custom attributes cannot be the same.

Example

The following example shows an AssociationSet element that represents the FK_CustomerOrders foreign key constraint in the underlying database:

<AssociationSet Name="FK_CustomerOrders" 
                Association="ExampleModel.Store.FK_CustomerOrders">
  <End Role="Customers" EntitySet="Customers" />
  <End Role="Orders" EntitySet="Orders" />
</AssociationSet>

See Also

Concepts

Entity Framework Overview
SSDL Specification
EntitySet Element (SSDL)

Other Resources

CSDL, SSDL, and MSL Specifications
ADO.NET Entity Data Model Tools