Chapter 21. Using the Entity Framework in n-Tier ASP.NET Applications
The preceding chapter focused on using the Entity Framework in an
n-tier client-side application, as well as some of
the UI challenges that you should be aware of. One of the key factors is
that you were able to leverage a long-lived ObjectContext
whose entities remain attached as
they move into the UI and back. This allowed you to take advantage of
Object Services change tracking.
Web applications are a completely different ballgame posing a new
set of challenges for tracking changes in entities. Here, the client is a
web page and the short-lived life cycle of a web page prevents entities
from remaining attached to an ObjectContext
. Additionally, because of the
nature of server-based applications, any objects in memory are maintained
on the server. For the developer, this means the server is responsible for
maintaining objects for every user that is accessing the website at a
given time, which could add up very quickly.
The biggest challenge of removing the UI’s direct dependency on the
Entity Framework in web applications is to figure out how to provide the
state information that SaveChanges
needs for updates in a way that
balances the load between the client machine of the person accessing your
site and the server. At the same time, you want to try to avoid
unnecessary round trips to the database.
The EntityDataSource
control goes
a long way toward solving these problems; however, the EntityDataSource
lives completely ...
Get Programming Entity Framework 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.