次の方法で共有


ReferentialConstraint 要素 (EntityContainer CSDL)

エンティティ データ モデル (EDM) では、アソシエーションの Principal RoleDependent Role は、概念スキーマ定義言語 (CSDL) の ReferentialConstraint 要素によって指定されます。参照に関する制約は、ObjectContext における関連オブジェクトの動作に影響します。詳細については、「参照に関する制約 (Entity Framework)」を参照してください。

次のアソシエーションでは、VendorAddress 型は Address 型に依存しています。VendorAddressAddressVendor とリンクするだけなので、アドレス オブジェクトは複数の VendorAddress オブジェクトに関連付けることができます。Vendor は複数の Address を持つことができます。

  <Association Name="FK_VendorAddress_Address_AddressID">
    <End Role="Address" Type="Adventureworks.Address" Multiplicity="1" />
    <End Role="VendorAddress" Type="Adventureworks.VendorAddress" Multiplicity="*" />
    <ReferentialConstraint>
      <Principal Role="Address">
        <PropertyRef Name="AddressID" />
      </Principal>
      <Dependent Role="VendorAddress">
        <PropertyRef Name="AddressID" />
      </Dependent>
    </ReferentialConstraint>
  </Association>

<EntityType Name="VendorAddress">
    <Key>
      <PropertyRef Name="VendorID" />
      <PropertyRef Name="AddressID" />
    </Key>
    <Property Name="VendorID" Type="Int32" Nullable="false" />
    <Property Name="AddressID" Type="Int32" Nullable="false" />
    <Property Name="ModifiedDate" Type="DateTime" Nullable="false" />
    <NavigationProperty Name="Address"
     Relationship="Adventureworks.FK_VendorAddress_Address_AddressID"
       FromRole="VendorAddress" ToRole="Address" />
    <NavigationProperty Name="AddressType"
Relationship="Adventureworks.FK_VendorAddress_AddressType_AddressTypeID
   " FromRole="VendorAddress" ToRole="AddressType" />
    <NavigationProperty Name="Vendor"
     Relationship="Adventureworks.FK_VendorAddress_Vendor_VendorID"
     FromRole="VendorAddress" ToRole="Vendor" />
  </EntityType>

<EntityContainer Name="AdventureworksContext">

   <EntitySet Name="VendorAddress" 
          EntityType="Adventureworks.VendorAddress" />

  <AssociationSet Name="FK_VendorAddress_Address_AddressID"
     Association="Adventureworks.FK_VendorAddress_Address_AddressID">
      <End Role="Address" EntitySet="Address" />
      <End Role="VendorAddress" EntitySet="VendorAddress" />
  </AssociationSet>

</EntityContainer>

参照

概念

AssociationSet 要素 (EntityContainer CSDL)