AssociationSet Element (EntityContainer SSDL)
In the Entity Data Model (EDM), the AssociationSet element in store schema definition language (SSDL) specifies an association in the storage metadata.
The object model that will be built from the conceptual schema requires both programmable classes and storage structures to contain data for applications built on the model. An AssociationSetMapping in mapping specification language (MSL) connects the AssociationSet defined in conceptual schema definition language (CSDL) to the AssociationSet in SSDL that describes the storage structures.
The following CSDL syntax shows the declaration of an AssociationSet named FK_Employee_Employee_ManagerID in the AdventureWorks.Store schema. This AssociationSet is part of the EntityContainer named AdventureWorks.Store in the AdventureWorks metadata. Although this EntityContainer is defined in the AdventureWorks.Store schema, the EntityContainer is an independent element.
The AssociationSet element assigns a Name and identifies the AssociationType used in this association set designation.
<EntityContainer Name="Adventureworks.Store">
<AssociationSet Name="FK_Employee_Employee_ManagerID"
Association="Adventureworks.Store.FK_Employee_Employee_ManagerID">
<End Role="Employee" EntitySet="Employee" />
<End Role="Employee1" EntitySet="Employee" />
</AssociationSet>
</EntityContainer>
<Association Name="FK_Employee_Employee_ManagerID">
<End Role="Employee" Type="Adventureworks.Store.Employee" Multiplicity="0..1" />
<End Role="Employee1" Type="Adventureworks.Store.Employee" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Employee">
<PropertyRef Name="EmployeeID" />
</Principal>
<Dependent Role="Employee1">
<PropertyRef Name="ManagerID" />
</Dependent>
</ReferentialConstraint>
</Association>
In this example, the ReferentialConstraint element indicates that associations depend on database structures. The ReferentialConstraint specifies a Principal Role and Dependent Role and, most important, a PropertyRef for each role that corresponds to foreign key relationship in the database.
The PropertyRef of the Principal Role specifies the property that is assigned to a foreign key column of the Employee database table. The PropertyRef of the Dependent Role specifies the column that holds the foreign key. For example, in the FK_Employee_Employee_ManagerID association, the PropertyRef of the Dependent Role is the EmployeeID property of the manager employee contained by the ManagerID foreign key column of the Employee table. For a complete example that uses the ReferentialConstraint, see Implementing Associations (EDM).
When the programming object model is built, entities of the FK_Employee_Employee_ManagerID type can be instantiated in application code.
For completeness, the declaration of the AssociationType is included in the example after the EntityContainer and AssociationSet definitions.
See Also
Concepts
AssociationSet Element (EntityContainer CSDL)
EntitySetMapping Element (MSL)
Entity Sets (EDM)
Association Sets (EDM)
AdventureWorks Complete Model (EDM)