Chapter 19. Working with Relationships and Associations
At this point in the book, you have worked extensively with entities
that are related to one another. You have also experienced a number of
scenarios where it was necessary to do extra work to an object because of
its associations. You learned that if an EntitySet
is mapped using a QueryView
, every other related entity also needs
to be mapped using a QueryView
. In
building a WCF service in Chapter 17, you had to do a little
extra work to make sure that when inserting new Reservation
s, the context did not also attempt
to add a new Trip
entity.
So much happens behind the scenes as the Entity Framework manages entities and their relationships that unexpected behaviors and seemingly strange errors can sometimes result, unless you follow the rules designed to maintain these relationships.
In this chapter, you’ll learn how relationships and associations fit
into the EDM and how they work both inside and outside the ObjectContext
. With this knowledge, you will be better prepared to manipulate relationships between entities, adding or removing relationships between objects in the way that the Entity Framework expects; you will be able to solve problems that arise because of relationships; you will even enhance your ability to build more meaningful Entity Data Models. All the while, you’ll be able to perform these tasks in the manner that Entity Framework expects. And if you happen to break an Entity Framework rule, hopefully this knowledge ...
Get Programming Entity Framework, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.