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
Publisher resources
Table of contents
- Programming Entity Framework: DbContext
- 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: 9781449331849
You might also like
book
Programming Entity Framework: Code First
Take advantage of the Code First data modeling approach in ADO.NET Entity Framework, and learn how …
book
Microsoft ADO.NET Entity Framework Step by Step
Your hands-on guide to Entity Framework fundamentals Expand your expertise—and teach yourself the fundamentals of the …
book
Entity Framework 6 Recipes, Second Edition
Entity Framework 6 Recipes provides an exhaustive collection of ready-to-use code solutions for Entity Framework, Microsoft's …
book
Modern Data Access with Entity Framework Core: Database Programming Techniques for .NET, .NET Core, UWP, and Xamarin with C#
C# developers, here’s your opportunity to learn the ins-and-outs of Entity Framework Core, Microsoft’s recently redesigned …