Contents
Chapter 1: Getting Started with Entity Framework
1-1. A Brief Tour of the Entity Framework World
Chapter 2: Entity Data Modeling Fundamentals
2-2. Creating a Model from an Existing Database
2-3. Modeling a Many-to-Many Relationship with No Payload
2-4. Modeling a Many-to-Many Relationship with a Payload
2-5. Modeling a Self-Referencing Relationship with a Code-First Approach
2-6. Splitting an Entity Among Multiple Tables
2-7. Splitting a Table Among Multiple Entities
2-8. Modeling Table per Type Inheritance
2-9. Using Conditions to Filter an ObjectSet
2-10. Modeling Table per Hierarchy Inheritance
2-11. Modeling Is-a and Has-a Relationships Between Two Entities
2-12. Creating, Modifying, and Mapping Complex Types
Chapter 3: Querying an Entity Data Model
3-2. Updating with Native SQL Statements
3-3. Fetching Objects with Native SQL Statements
3-4. Querying a Model with Entity SQL
3-5. Finding a Master That Has Detail in a Master-Detail Relationship
3-6. Setting Default Values in a Query
3-7. Returning Multiple Result Sets from a Stored Procedure
3-8. Comparing Against a List of Values
3-9. Filtering Related Entities
3-10. Applying a Left-Outer Join
3-11. Ordering by Derived Types
3-14. Flattening Query Results
3-15. Grouping by Multiple Properties
3-16. Using Bitwise Operators in a Filter
3-17. Joining on Multiple Columns
Chapter 4: Using Entity Framework in ASP.NET MVC
4.1. Building CRUD Operations in an ASP.NET MVC Page
4-3. Filtering with ASP.NET’s URL Routing
Chapter 5: Loading Entities and Navigation Properties
5-1. Lazy Loading Related Entities
5-2. Eager Loading Related Entities
5-3. Finding Single Entities Quickly
5-4. Querying In-Memory Entities
5-5. Loading a Complete Object Graph
5-6. Loading Navigation Properties on Derived Types
5-7. Using Include( ) with Other LINQ Query Operators
5-8. Deferred Loading of Related Entities
5-9. Filtering and Ordering Related Entities
5-10. Executing Aggregate Operations on Related Entities
5-11. Testing Whether an Entity Reference or Entity Collection Is Loaded
5-12. Loading Related Entities Explicitly
5-13. Filtering an Eagerly Loaded Entity Collection
5-14. Modifying Foreign Key Associations
Chapter 6: Beyond the Basics with Modeling and Inheritance
6-1. Retrieving the Link Table in a Many-to-Many Association
6-2. Exposing a Link Table as an Entity
6-3. Modeling a Many-to-Many, Self-Referencing Relationship
6-4. Modeling a Self-Referencing Relationship Using Table per Hierarchy Inheritance
6-5. Modeling a Self-Referencing Relationship and Retrieving a Complete Hierarchy
6-6. Mapping Null Conditions in Derived Entities
6-7. Modeling Table per Type Inheritance Using a Nonprimary Key Column
6-8. Modeling Nested Table per Hierarchy Inheritance
6-9. Applying Conditions in Table per Type Inheritance
6-10. Creating a Filter on Multiple Criteria
6-11. Using Complex Conditions with Table per Hierarchy Inheritance
6-12. Modeling Table per Concrete Type Inheritance
6-13. Applying Conditions on a Base Entity
6-14. Creating Independent and Foreign Key Associations
6-15. Changing an Independent Association into a Foreign Key Association
Chapter 7: Working with Object Services
7-1. Dynamically Building a Connection String
7-2. Reading a Model from a Database
7-4. Using the Pluralization Service
7-5. Retrieving Entities from the Change Tracker
7-6. Generating a Model from the Command Line
7-7. Working with Dependent Entities in an Identifying Relationship
7-8. Inserting Entities Using a Database Context
7-9. Querying and Saving Asynchronously
Chapter 8: Plain Old CLR Objects
8-2. Loading Related Entities with POCO
8-4. POCO with Complex Type Properties
8-5. Notifying Entity Framework About Object Changes
8-6. Retrieving the Original (POCO) Object
8-7. Manually Synchronizing the Object Graph and the Change Tracker
8-9. Testing a Repository Against a Database
Chapter 9: Using the Entity Framework in N-Tier Applications
9-1. Updating Single Disconnected Entities with the Web API
9-2. Updating Disconnected Entities with WCF
9-3. Finding Out What Has Changed with Web API
9-4. Implementing Client-Side Change Tracking with Web API
9-5. Deleting an Entity When Disconnected
9-6. Managing Concurrency When Disconnected
9-7. Serializing Proxies in a WCF Service
10-1. Returning an Entity Collection with Code Second
10-2. Returning Output Parameters
10-3. Returning a Scalar Value Result Set
10-4. Returning a Complex Type from a Stored Procedure
10-5. Defining a Custom Function in the Storage Model
10-6. Populating Entities in a Table per Type Inheritance Model
10-7. Populating Entities in a Table per Hierarchy Inheritance Model
10-8. Mapping the Insert, Update, and Delete Actions to Stored Procedures
10-9. Using Stored Procedures for the Insert and Delete Actions in a Many-to-Many Association
11-1. Returning a Scalar Value from a Model-Defined Function
11-2. Filtering an Entity Collection Using a Model-Defined Function
11-3. Returning a Computed Column from a Model-Defined Function
11-4. Calling a Model-Defined Function from a Model-Defined Function
11-5. Returning an Anonymous Type from a Model-Defined Function
11-6. Returning a Complex Type from a Model-Defined Function
11-7. Returning a Collection of Entity References from a Model-Defined Function
11-8. Using Canonical Functions in eSQL
11-9. Using Canonical Functions in LINQ
11-10. Calling Database Functions in eSQL
11-11. Calling Database Functions in LINQ
11-12. Defining Built-in Functions
Chapter 12: Customizing Entity Framework Objects
12-1. Executing Code When SaveChanges( ) Is Called
12-2. Validating Property Changes
12-3. Logging Database Connections
12-4. Recalculating a Property Value When an Entity Collection Changes
12-5. Automatically Deleting Related Entities
12-6. Deleting All Related Entities
12-7. Assigning Default Values
12-8. Retrieving the Original Value of a Property
12-9. Retrieving the Original Association for Independent Associations
12-11. Applying Server-Generated Values to Properties
12-12. Validating Entities on Saving Changes
Chapter 13: Improving Performance
13-1. Optimizing Queries in a Table per Type Inheritance Model
13-2. Retrieving a Single Entity Using an Entity Key
13-3. Retrieving Entities for Read-Only Access
13-4. Efficiently Building a Search Query
13-5. Making Change Tracking with POCO Faster
13-6. Auto-Compiling LINQ Queries
13-7. Returning Partially Filled Entities
13-8. Moving an Expensive Property to Another Entity
13-10. Generating Proxies Explicitly
14-1. Applying Optimistic Concurrency
14-2. Managing Concurrency When Using Stored Procedures
14-3. Reading Uncommitted Data
14-4. Implementing the “Last Record Wins” Strategy
14-5. Getting Affected Rows from a Stored Procedure
14-6. Optimistic Concurrency with Table Per Type Inheritance