ReferentialConstraint 元素(关联 SSDL)

Association 中的 ReferentialConstraint 元素在实体数据模型 (EDM) 中用存储架构定义语言 (SSDL) 指定关系的方向。SSDL 中的 ReferentialConstraint 基于数据源中的外键约束。EDM 中的关联可在双方向上导航;ReferentialConstraintPrincipal RoleDependent Role 元素的角色在数据库中具有对应的外键关系。

下面的架构使用 ReferentialConstraint 元素的 Principal RoleDependent 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>

另请参见

概念

Association 元素 (CSDL)
导航属性 (EDM)