Association 中的 ReferentialConstraint 元素在实体数据模型 (EDM) 中用存储架构定义语言 (SSDL) 指定关系的方向。SSDL 中的 ReferentialConstraint 基于数据源中的外键约束。EDM 中的关联可在双方向上导航;ReferentialConstraint 的 Principal Role 和 Dependent Role 元素的角色在数据库中具有对应的外键关系。
下面的架构使用 ReferentialConstraint 元素的 Principal Role 和 Dependent Role 属性指定方向。在数据表中,DependentRole 具有包含 ManagerID 的外键。
  <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>