Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
foreign key property (Entity Data Model)
A foreign key property in the Entity Data Model (EDM) is a primitive type property (or a set of primitive type properties) on an entity type that contains the entity key of another entity type.
A foreign key property is analogous to a foreign key column in a relational database. In the same way that foreign key columns are used in a relational database to create relationships between rows in tables, foreign key properties in a conceptual model are used to establish associations between entity types. A referential integrity constraint is used to define an association between two entity types when one of the types has a foreign key property.
Example
The diagram below shows a conceptual model with three entity types: Book, Publisher, and Author. The Book entity type has a property, PublisherId, that references the entity key of the Publisher entity type when you define a referential integrity constraint on the PublishedBy association.
Ee382822.RefConstraintModel(en-us,VS.100).gif
The ADO.NET Entity Framework uses a domain-specific language (DSL) called conceptual schema definition language (CSDL) to define conceptual models. The following CSDL uses the foreign key property PublisherId to define a referential integrity constraint on the PublishedBy association shown in the conceptual model shown above.
<Association Name="PublishedBy">
<End Type="BooksModel.Book" Role="Book" Multiplicity="*" >
</End>
<End Type="BooksModel.Publisher" Role="Publisher" Multiplicity="1" />
<ReferentialConstraint>
<Principal Role="Publisher">
<PropertyRef Name="Id" />
</Principal>
<Dependent Role="Book">
<PropertyRef Name="PublisherId" />
</Dependent>
</ReferentialConstraint>
</Association>