AssociationSet 元素 (SSDL)

以存储架构定义语言 (SSDL) 表示的 AssociationSet 元素表示基础数据库中的两个表之间的外键约束。 参与外键约束的表列在 Association 元素中指定。 对应于给定 AssociationSet 元素的 Association 元素在 AssociationSet 元素的 Association 特性中指定。

SSDL 关联集通过 AssociationSetMapping 元素映射到 CSDL 关联集。 不过,如果使用 ReferentialConstraint 元素定义给定 CSDL 关联集的 CSDL 关联,则没必要提供对应的 AssociationSetMapping 元素。 在这种情况下,如果存在一个 AssociationSetMapping 元素,则它定义的映射将被 ReferentialConstraint 元素覆盖。

AssociationSet 元素可以具有以下子元素(按所列顺序):

适用的特性

下表介绍可应用于 AssociationSet 元素的特性。

特性名称 是否必需

Name

关联集表示的外键约束的名称。

Association

定义参与外键约束的列的关联的名称。

Bb399601.note(zh-cn,VS.100).gif注意:
可以将任何数量的批注特性(自定义 XML 特性)应用于 AssociationSet 元素。然而,自定义特性可能不属于为 SSDL 保留的任何 XML 命名空间。任何两个自定义特性的完全限定名称都不能相同。

示例

下面的示例演示一个 AssociationSet 元素,该元素表示基础数据库中的 FK_CustomerOrders 外键约束:

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

另请参见

概念

实体框架概述
SSDL 规范
EntitySet 元素 (SSDL)

其他资源

CSDL、SSDL 和 MSL 规范
ADO.NET Entity Data Model Tools