Chapter 13. Updating Entities and Complex Types

The preceding three chapters about Entity Framework (EF) and the Entity Data Model (EDM) deal primarily with mapping from the store to the conceptual schema and querying the EDM with Entity SQL (eSQL) and LINQ to Entities. This chapter primarily addresses create, update, and delete (CUD) operations on entity instances and collections, including optimistic concurrency management. It also covers the process of detaching entities from an existing ObjectContext instance and attaching them to new ObjectContext instances, which is an important factor in the use of the EDM as a data source in n-tier, service-oriented applications.

The chapter also deals with mapping and updating complex types, which also are known as value objects. Complex types are data structures, which resemble entities that have multiple properties but don't have a unique identity. The most common example of a complex type is Address, which might have StreetAddress, City, Region, PostalCode, and Country properties.

Sample projects for this chapter are in the \WROX\ADONET\Chapter13\CS and ... \VB folders.

Understanding the ObjectContext's ObjectStateManager and Its Children

Chapter 9's "ObjectStateManager" section introduced you to EF's ObjectContext.ObjectStateManager, which is responsible for managing entity instances' identity, providing change tracking, and supplying a change set that you can use for resolving concurrency conflicts. Chapter 9's primary context is an overview ...

Get Professional ADO.NET 3.5 with LINQ and the 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.