Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Julia Lerman

Rating No ratings yet

Get a thorough introduction to ADO.NET Entity Framework 4 -- Microsoft's core framework for modeling and interacting with data in .NET applications. The second edition of this acclaimed guide provides a hands-on tour of the framework latest version in Visual Studio 2010 and .NET Framework 4. Not only will you learn how to use EF4 in a variety of applications, you'll also gain a deep understanding of its architecture and APIs. Written by Julia Lerman, the leading independent authority on the framework, Programming Entity Framework covers it all -- from the Entity Data Model and Object Services to WCF Services, MVC Apps, and unit testing. This book highlights important changes for experienced developers familiar with the earlier version.Understand the core concepts you need to make the best use of the EF4 in your applications Learn to query your data, using either LINQ to Entities or Entity SQL Create Windows Forms, WPF, ASP.NET Web Forms, and ASP.NET MVC applications Build and consume WCF Services, WCF Data Services, and WCF RIA Services Use Object Services to work directly with your entity objects Create persistent ignorant entities, repositories, and write unit tests Delve into model customization, relationship management, change tracking, data concurrency, and more Get scores of reusable examples -- written in C# (with notes on Visual Basic syntax) -- that you can implement right away

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# Programming Entity Framework, Second Edition — Reading Guide ## 【One-Line Pitch】 A comprehensive, hands-on guide to ADO.NET Entity Framework 4 for .NET developers who want to master Microsoft's core data-access framework—covering everything from modeling and querying to building real-world applications with WCF, MVC, and unit testing. ## 【Book Arc】 - **Opening (~0%–9%)**: Introduces EF4's architecture, the Entity Data Model (EDM), and the tooling in Visual Studio 2010, establishing the conceptual foundation—entities, associations, and the designer—before diving into code. - **Early (~9%–25%)**: Covers querying fundamentals with LINQ to Entities and Entity SQL, including navigation properties, projections, and how queries translate to database commands, with practical examples in C# and VB. - **Early–Middle (~25%–38%)**: Explores deeper query techniques—shaped results, explicit loading, Entity SQL operators, and query builder methods—then transitions into change tracking and how ObjectContext manages entity states during SaveChanges. - **Middle (~38%–47%)**: Moves into real-world modeling with complex relationships (many-to-many, self-referencing) and data binding in Windows Forms and WPF, including the Include method for eager loading and handling child data in grids. - **Late (~47%–end)**: Addresses enterprise concerns: POCOs and self-tracking entities for WCF services, layered client-side and web applications (Web Forms and MVC), repositories, unit testing, and model-first design—plus a look at future technologies like Code First and "M." ## 【Key Takeaways】 - **The Entity Data Model is the heart of EF4** (Early): Understanding the three layers—conceptual, store, and mapping—explains how EF translates your object queries into database commands, making architecture knowledge essential before writing code. - **Foreign keys in entities are new and optional in EF4** (Early): Unlike version 1, EF4 includes foreign key properties by default, which simplifies change tracking and relationship management, but you can still build models the old way for backward compatibility. - **Multiplicity defines relationship semantics** (Early): The 1, *, and 0..1 cardinality options determine how associations behave—for example, "0..1:*" means a shipper may have many orders, but an order may have zero or one shipper. - **LINQ to Entities gives you compile-time IntelliSense** (Early): Because the compiler knows entity types, you get property suggestions as you type—a major productivity win over raw SQL or Entity SQL strings. - **EntityClient requires sequential column access** (Early): When using ExecuteReader, you must read columns in the order they stream; this memory-control rule forces you to plan your data extraction carefully. - **SaveChanges is efficient because of ObjectStateEntry tracking** (Middle): The ObjectContext inspects state entries, ignores Unchanged entities, and only builds commands for Modified, Added, or Deleted ones—so you don't pay for untouched data. - **The Include method eagerly loads related data but can be wasteful** (Middle): A query with multiple Includes returns a full object graph, but as the author warns, it can produce "gasp"-inducing SQL and redundant data—use it deliberately, not as a default. - **Deleting child rows in grids doesn't delete from the database** (Middle): Removing a reservation from a grid only removes it from the collection; you need explicit handling to persist deletions—a gotcha that applies beyond EF to DataSets and custom objects. ## 【Reading Tips】 - **Skim the early architecture chapters** (~0%–9%) if you're already familiar with EF v1; focus instead on the "what's new" callouts about foreign keys and model-first design. - **Deep-read the querying chapters** (~9%–25%)—they're the foundation for everything else; pay special attention to the LINQ vs. Entity SQL comparisons and the translation-to-SQL explanations. - **Watch for the "not a best practice" warnings** (e.g., the Include-heavy query in Chapter 9); the author explicitly flags anti-patterns, which are as instructive as the recommended approaches. - **The later enterprise chapters** (~47%–end) assume you've absorbed the earlier material; if you're only building simple apps, you can skim the WCF and layered-architecture content. - **Keep the appendixes in mind**—they cover assemblies, data-binding quirks, and metadata XML, which are useful references when you hit edge cases in real projects. ## 【Coverage Limits】 This guide synthesizes the opening through middle sections (~47% of the book); the later chapters on WCF services, POCOs, layered applications, and model-first design are summarized from the preface but not detailed here. ##
Page 16
es with a Base Class 493 Following WCF Collection Rules 495 Preventing Properties from Being Marked As Virtual 496 Building a WCF Service That Uses POCO Clas...
View in text
Excerpt 2
but doing so is not as critical as having plural EntitySet names because you won’t be interacting with the AssociationSets in code. Learn more about Associat...
View in text
Excerpt 3
act.Addresses.Load(); Console.WriteLine(contact.Addresses.Count); } When Load is called, Object Services will execute a query to retrieve all of the addres...
View in text
Excerpt 4
s and Trip don’t have a lot of fields, either. But a lot of redundant data will be sent back to the application. For example, each customer who Data Binding ...
View in text
Excerpt 5
d to be used with the EntityClient provider, or not valid.” 242 | Chapter 10: Working with Object Services var destinationEntityKey = _context.CreateEntityKe...
View in text
Excerpt 6
ve an EntitySet value if you also have a CommandText value. Binding a DropDownList to an EntityDataSource Control The last task for the first pass at this we...
View in text
Excerpt 7
this sidebar, there are a lot of caveats to using QueryView. Essentially it can turn into an all-or-nothing mapping choice in your model because of the requi...
View in text
Excerpt 8
xt immediately. With the possibility that many clients will make many calls to your services, you don’t want to have any of those contexts or connections han...
View in text
Tags
AI categories
BackendDatabaseC#
Language: English
File Format: PDF
File Size: 10.4 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…