Elemento ReferentialConstraint (EntityContainer CSDL)
En Entity Data Model (EDM), el elemento ReferentialConstraint del lenguaje de definición de esquemas conceptuales (CSDL) especifica la Principal Role y la Dependent Role de una asociación. Las restricciones referenciales afectan al comportamiento de los objetos relacionados en un ObjectContext. Para obtener más información, vea Restricciones referenciales (Entity Framework).
En la asociación siguiente, el tipo VendorAddress depende del tipo Address. Un objeto Address puede estar relacionado con varios objetos VendorAddress porque VendorAddress simplemente vincula una Address (dirección) a un Vendor (proveedor). Un Vendor puede tener más de una 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>