Book description
The DbContext API captures Entity Framework’s (EF) most commonly used features and tasks, simplifying development with EF. This concise book shows you how to use the API to perform set operations with the DbSet class, handle change tracking and resolve concurrency conflicts with the Change Tracker API, and validate changes to your data with the Validation API.
With DbContext, you’ll be able to query and update data, whether you’re working with individual objects or graphs of objects and their related data. You’ll find numerous C# code samples to help you get started. All you need is experience with Visual Studio and database management basics.
- Use EF’s query capabilities to retrieve data, and use LINQ to sort and filter data
- Learn how to add new data, and change and delete existing data
- Use the Change Tracker API to access information EF keeps about the state of entity instances
- Control change tracking information of entities in disconnected scenarios, including NTier applications
- Validate data changes before they’re sent to the database, and set up validation rules
- Bypass EF’s query pipeline and interact directly with the database
Table of contents
- Preface
- 1. Introducing the DbContext API
- 2. Querying with DbContext
- 3. Adding, Changing, and Deleting Entities
-
4. Working with Disconnected Entities Including N-Tier
Applications
- A Simple Operation on a Disconnected Graph
- Exploring the Challenges of N-Tier
- Understanding How DbContext Responds to Setting the State of a Single Entity
- Setting the State for Multiple Entities in an Entity Graph
- Building a Generic Approach to Track State Locally
- Tracking Individually Modified Properties
-
5. Change Tracker API
- Change Tracking Information and Operations for a Single Entity
- Working with the State Property
- Working with Current, Original, and Database Values
- Working with Individual Properties
- Refreshing an Entity from the Database
- Change Tracking Information and Operations for Multiple Entities
- Using the Change Tracker API in Application Scenarios
-
6. Validating with the Validation API
- Defining and Triggering Validation: An Overview
- Validating a Single Object on Demand with GetValidationResult
- Specifying Property Rules with ValidationAttribute Data Annotations
- Inspecting Validation Result Details
- Exploring More ValidationAttributes
- Validating Individual Properties on Demand
- Specifying Type-Level Validation Rules
- Understanding How EF Combines Validations
- Validating Multiple Objects
- Validating When Saving Changes
- 7. Customizing Validations
-
8. Using DbContext in Advanced
Scenarios
- Moving Between ObjectContext and DbContext
- Leveraging SQL Server Operators Exposed in SqlFunctions
- Querying Derived Types with DbSet
- Understanding the Interface Property Limitation
- Considering Automated Testing with DbContext
- Reducing Database Hits in Testing with IDbSet
- Accessing the Database Directly from DbContext
- Providing Multiple Targeted Contexts in Your Application
- 9. What’s Coming Next for Entity Framework
- About the Authors
- Copyright
Product information
- Title: Programming Entity Framework: DbContext
- Author(s):
- Release date: February 2012
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781449312961
You might also like
book
Generative Deep Learning, 2nd Edition
Generative AI is the hottest topic in tech. This practical book teaches machine learning engineers and …
book
Designing Data-Intensive Applications
Data is at the center of many challenges in system design today. Difficult issues need to …
book
High-Performance Programming in C# and .NET
Enhance your applications' performance using best practices for benchmarking, application profiling, asynchronous programming, designing responsive UIs, …
book
Software Architect's Handbook
A comprehensive guide to exploring software architecture concepts and implementing best practices Key Features Enhance your …