Database Reference
In-Depth Information
5-14. Modifying Foreign Key Associations
Problem
You want to modify a foreign key association.
Solution
Entity Framework provides a couple of ways to modify a foreign key association. You can add the associated entity to
a navigation property collection or assign it to a navigation property. You can also set the foreign key value with the
associated entity's key value.
Suppose that you have a model like the one shown in Figure 5-29 .
Figure 5-29. A model for clients and invoices
To modify the foreign key association between client entities and invoice entities in two different ways, do the
following:
1.
Right-click your project, and select Add New ADO.NET Entity Data Model. Import the
Client and Invoice tables. Be certain that the Include foreign key columns in the model
check box is checked, which is the default behavior, as shown in Figure 5-30 . Doing
so will import foreign key associations from the database that are not many-to-many
relationships.
 
Search WWH ::




Custom Search