Programming Entity Framework
Publisher: O'Reilly Media
Release Date: February 2009
Pages: 832
Read on Safari with a 10-day trial
Start your free trial now Buy on AmazonWhere’s the cart? Now you can get everything on Safari. To purchase books, visit Amazon or your favorite retailer. Questions? See our FAQ or contact customer service:
1-800-889-8969 / 707-827-7019
support@oreilly.com
If you use Entity Framework in Visual Studio 2008 and .NET 3.5, this is the book you want. Programming Entity Framework, 1st Edition offers experienced developers a thorough introduction to Microsoft's core framework for modeling and interacting with data in .NET applications. This hands-on tour provides a deep understanding of Entity Framework's architecture and APIs, and explains how to use the framework in a variety of applications built with Visual Studio 2008 and .NET 3.5.
From the Entity Data Model (EDM) and Object Services to EntityClient and the Metadata Workspace, this highly acclaimed first edition covers it all.
- Understand the core concepts you need to make the best use of the Entity Framework (EF) in your applications
- Learn to query your data, using either LINQ to Entities or Entity SQL
- Create Windows Forms, WPF, and ASP.NET applications
- Build ASMX web services and WCF services
- Use Object Services to work directly with your entity objects
- Delve into model customization, relationship management, change tracking, data concurrency, and more
One important note: while many of the lessons from this book will continue to be valuable as you move to .NET 4, the thoroughly revised second edition of Programming Entity Framework (August 2010) specifically targets Visual Studio 2010 and .NET 4 -- where there have been many advancements and additions to the framework.
Table of Contents
-
Chapter 1 Introducing the ADO.NET Entity Framework
-
Programming Against a Model, Not Against the Database
-
The Entity Data Model: A Client-Side Data Model
-
The Entity in “Entity Framework”
-
Choosing Your Backend
-
Entity Framework Features
-
The Entity Framework in Web Services
-
What About ADO.NET DataSets and LINQ to SQL?
-
Entity Framework Pain Points
-
Programming the Entity Framework
-
-
Chapter 2 Exploring the Entity Data Model
-
Why Use an Entity Data Model?
-
The EDM Within the Entity Framework
-
Your First EDM
-
The EDM in the Designer Window
-
Entity Properties
-
The Naked Model: Inspecting the Model’s XML
-
A Less Daunting Model View
-
The Three Parts of the Model
-
CSDL: The Conceptual Schema
-
SSDL: The Store Schema
-
MSL: The Mappings
-
Database Views in the EDM
-
Code Generation from EDM to Classes
-
Summary
-
-
Chapter 3 Querying Entity Data Models
-
Query the Model, Not the Database
-
Your First EDM Query
-
LINQ to Entities Queries
-
Entity SQL Queries That Return Objects
-
Method-Based Syntax Queries for LINQ and Entity SQL
-
The Shortest Query
-
EntityClient: The Lowest-Level Method for Returning Streamed Data Through EDM Queries
-
Translation to Database Queries
-
Avoid Inadvertent Query Execution
-
Summary
-
-
Chapter 4 Exploring EDM Queries in Greater Depth
-
Same Model, Friendlier Name
-
Projections in Queries
-
Projections in Entity SQL
-
Querying Across Associations
-
Joins and Nested Queries
-
Grouping
-
Shaped Data Returned by Queries
-
Deferred Loading and Eager Loading Queries
-
Retrieving a Single Entity
-
Retrieving a Single Entity with GetObjectByKey
-
Entity SQL’s Wrapped and Unwrapped Results
-
Summary
-
-
Chapter 5 Modifying Entities and Saving Changes
-
How ObjectContext Manages Entities
-
The SaveChanges Method
-
Adding New Entities
-
Inserting New Parents and Children
-
Deleting Entities
-
Summary
-
-
Chapter 6 Using Stored Procedures with the EDM
-
Adding the Stored Procedures into the Model
-
Working with Functions
-
Implementing Functions
-
The EDM Designer’s Model Browser
-
Mapping the Last of the Four Functions: CustomersbyState
-
More About the Update Model Wizard
-
Summary
-
-
Chapter 7 Tuning Up a Model
-
The BreakAway Geek Adventures Business Model
-
Creating a Class Library Project to Host an EDM
-
Inspecting and Cleaning Up a New Model
-
Cleaning Up Navigation Property Names
-
Mapping a Few Stored Procedures
-
Working with Many-to-Many Relationships
-
Building the BreakAwayModel Project
-
Summary
-
-
Chapter 8 Data Binding with Windows Forms and WPF Applications
-
Data Binding with Windows Forms Applications
-
Data Binding with WPF Applications
-
Summary
-
-
Chapter 9 Working with Object Services
-
Where Does Object Services Fit into the Framework?
-
Query Processing
-
Object Materialization
-
The ObjectContext
-
State Management and ObjectStateEntry
-
Relationship Management
-
Sending Changes Back to the Database
-
Additional Features
-
Summary
-
-
Chapter 10 Customizing Entities
-
Partial Classes
-
Customizable Methods
-
Customizable Event Handlers
-
Other Opportunities for Customization
-
Summary
-
-
Chapter 11 Using the ASP.NET EntityDataSource Control
-
Getting to First Base with the EntityDataSource Control and Flat Data
-
Understanding How the EntityDataSource Is Able to Retrieve and Update Your Data
-
Working with Related EntityReference Data
-
Working with Hierarchical Data in a Master/Detail Form
-
Browsing Through the EntityDataSource Events
-
Summary
-
-
Chapter 12 Customizing Entity Data Models
-
Designer Support for Mappings
-
Mapping Table per Type Inheritance for Tables That Describe Derived Types
-
Using Entity Splitting to Map a Single Entity to More Than One Table
-
Using Conditional Mapping to Filter Entity Mappings
-
Implementing Table per Hierarchy Inheritance for Tables That Contain Multiple Types
-
Implementing Customizations That Are Not Supported by the EDM Designer
-
Mapping Table per Concrete (TPC) Type Inheritance for Tables with Overlapping Fields
-
Creating Complex Types to Encapsulate Sets of Properties
-
Using QueryView to Create Read-Only Entities and Other Specialized Mappings
-
Additional Customization Options
-
Summary
-
-
Chapter 13 Working with Stored Procedures When Function Mapping Won’t Do
-
Does the Procedure Line Up with an Entity?
-
Overview of Procedures, UDFs, and TVFs in the EDM
-
Composing Queries Against Functions
-
Mapping and Executing Query Stored Procedures
-
Adding Native Queries to the Model
-
Adding Native Views to the Model
-
Using Commands That Affect the Persisted Database
-
Defining Insert, Update, and Delete Stored Procedures Directly in the Model
-
Mapping Insert/Update/Delete to Types Within an Inheritance Structure
-
Implementing and Querying with User-Defined Functions (UDFs)
-
Summary
-
-
Chapter 14 Using Entities with Web and WCF Services
-
Building a Client That Is Ignorant of the Entity Framework
-
Using the Entity Framework with ASMX Web Services
-
Using the Entity Framework with WCF Services
-
Summary
-
-
Chapter 15 Working with Relationships and Associations
-
Deconstructing Relationships in the Entity Data Model
-
Deconstructing Relationships Between Instantiated EntityObjects
-
Defining Relationships Between Entities
-
Learning a Few Last Tricks to Make You a Relationship Pro
-
Summary
-
-
Chapter 16 Making It Real: Connections, Transactions, Performance, and More
-
EntityConnection and Database Connections in the Entity Framework
-
The Entity Framework and Transactions
-
The Entity Framework and Security
-
The Entity Framework and Performance
-
Entities in Multithreaded Applications
-
Summary
-
-
Chapter 17 Controlling Objects with ObjectStateManager and MetadataWorkspace
-
Managing ObjectStateEntry Objects with ObjectStateManager
-
Getting an ObjectStateManager and Its Entries
-
CurrentValues and OriginalValues
-
Building the ObjectStateEntry Visualizer
-
ObjectStateManager and SavingChanges
-
The MetadataWorkspace API
-
Creating EntityObjects Without Entity Classes
-
Creating Entities and Graphs Dynamically
-
Summary
-
-
Chapter 18 Handling Entity Framework Exceptions
-
Preparing for Exceptions in Entity Framework Code
-
EntityConnectionString Exceptions
-
Query Compilation Exceptions
-
Creating a Common Wrapper to Handle Query Execution Exceptions
-
SaveChanges Command Execution Exceptions
-
ObjectStateEntries Returned by Object Services Exceptions
-
InvalidOperationExceptions
-
Exceptions When Multiple Parties Edit Data Concurrently
-
Understanding Optimistic Concurrency Options in the Entity Framework
-
Implementing Optimistic Concurrency with the Entity Framework
-
Handling OptimisticConcurrencyExceptions
-
Handling Concurrency Exceptions at a Lower Level
-
Handling Exceptions When Transactions Are Your Own
-
Summary
-
-
Chapter 19 Using Your Own Custom Classes
-
Mapping Classes to the Entity Data Model
-
Implementing the IPOCO Interfaces
-
Custom Class Assemblies and Entity Data Model Files
-
Summary
-
-
Chapter 20 Using the Entity Framework in n-Tier Client-Side Applications
-
Thinking in Layers
-
Finding Your Motivation: A Master/Detail Data Entry Form That Will Use the DataBridge Class
-
Preventing Non-UI Logic from Leaking into the UI
-
Implementing Logic That Fits Best in the Entity Partial Classes
-
Building the CommandExecutor Class
-
Building the DataBridge Class
-
Using the DataBridge Class for Data Binding in a Master/Detail Form
-
Allowing Users to Roll Back Their Edits
-
Helping the User Who Forgets to Save Changes
-
Summary
-
-
Chapter 21 Using the Entity Framework in n-Tier ASP.NET Applications
-
Understanding How an ObjectContext Fits into the Web Page Life Cycle
-
Introducing ASP.NET’s ObjectDataSource Control
-
Designing Object Provider Classes to Be Used with an ObjectDataSource
-
Wiring Up the Provider Classes to ObjectDataSource Controls
-
Understanding Why We Didn’t Use Object Graphs in This Business Layer
-
Summary
-
-
Chapter 22 Implementing a Smarter WCF Service for Working with Entities
-
Will Your Client Agree to Your Data Contract?
-
Shipping DTOs, Not EntityObjects
-
Creating EntityState Properties That Do Not Rely on ObjectContext
-
Designing the Service Interface
-
Implementing the Service Operations
-
Implementing the Client That Will Use the WCF Service
-
Testing It All with a Simple Console Application
-
Summary
-
-
Chapter 23 The Entity Framework, Today and Tomorrow
-
What About Building Reports with the Entity Framework?
-
Extensions, Samples, and Solutions from Microsoft
-
Entity Framework v.Next
-
Blogs, Forums, and Other Resources
-
-
Appendix Entity Framework Assemblies and Namespaces
-
Unpacking the Entity Framework Files
-
Exploring the Namespaces
-
-
Colophon