Database Reference
In-Depth Information
Chapter 6
Beyond the Basics with Modeling
and Inheritance
By now you have a solid understanding of basic modeling techniques in Entity Framework. In this chapter, you will
find recipes that will help you address many common, and often complex, modeling problems. The recipes in this
chapter specifically address problems that you are likely to face in modeling existing, real-world databases.
We start this chapter by working with many-to-many relationships. This type of relationship is very common in
many modeling scenarios in both existing databases and new projects. Next we'll look at self-referencing relationships
and explore various strategies for retrieving nested object graphs. We round out this chapter with several recipes
involving more advanced modeling of inheritance and entity conditions.
6-1. Retrieving the Link Table in a Many-to-Many Association
Problem
You want to retrieve the keys in the link table that connect two entities in a many-to-many association.
Solution
Let's say that you have a model with a many-to-many association between Event and Organizer entities, as is shown
in Figure 6-1 .
Figure 6-1. Many-to-many association between Event and Organizer entities
 
Search WWH ::




Custom Search