Database Reference
In-Depth Information
If you choose to create a foreign key association, the model should look like the one shown in Figure 6-24 . If you
choose to create an independent association, the model should look like the one shown in Figure 6-25 .
Figure 6-24. A foreign key association between User and PasswordHistory
Figure 6-25. An independent association between User and PasswordHistory
How It Works
With a foreign key association, the foreign key is exposed as a property in the dependent entity. Exposing the foreign
key allows many aspects of the association to be managed with the same code that manages the other property values.
This is particularly helpful in disconnected scenarios, as we will see in Chapter 9. Foreign key associations are the
default in Entity Framework.
For independent associations, the foreign keys are not exposed as properties. This makes the modeling at the
conceptual layer somewhat cleaner because there is no noise introduced concerning the details of the association
implementation. In the early versions of Entity Framework, only independent associations were supported.
6-15. Changing an Independent Association into a Foreign Key
Association
Problem
You have a model that uses an independent association, and you want to change it to a foreign key association.
 
Search WWH ::




Custom Search