Pro Entity Framework 4.0

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Previously, SQL developers have been able to almost entirely ignore the SQLCLR and treat it as a peripheral technology—almost an extension to the main product. With the advent of LINQ and the Entity Framework, this is no longer the case, and the SQLCLR is moving to the center stage. It’s a powerful product but, for many, it is an entirely new way of working with data. Pro Entity Framework 4.0 will help readers understand the implications of the Entity Framework and how it can be used to change their development practices and make their databases more powerful and flexible. Since many readers will be encountering this subject for the first time, the book will create an inclusive environment in which the concepts of .NET development are approached from the perspective of the Relational T–SQL developer to foster a sense of shared–ownership in keeping with Microsoft’s latest best practices.

  • Comprehensive coverage of the new greater and more challenging integration with .NET 3.5
  • Written from a real–world perspective and examines the features offered by LINQ and the Entity Framework that will help solve problems experienced by professional developers
  • Contains insight, interpretation, analysis, and evangelism instead of just plain fact

What you’ll learn

  • Examine the SQLCLR architecture.
  • Learn the fundamentals of LINQ.
  • Use LINQ with SQL and datasets.
  • Extend LINQ.
  • Gain a holistic view of the features of LINQ and the Entity Framework and how they segue with other features of the .NET Framework and native features of the operating system.
  • Write practical applications of LINQ and the Entity Framework.

Who this book is for

.NET and SQL developers who use Microsoft SQL Server 2008 as their back–end database. Database administrators who create, manage, and secure those databases.

Table of Contents

Chapter 1: Introducing the ADO.NET 4.0 Entity Framework Chapter 2: The Entity Data Model Chapter 3: The Entity Data Model Inside and Out Chapter 4: Querying the EDM Chapter 5: Working with Entities Chapter 6: Stored Procedures and the EDM Chapter 7: Relationships and Associations Chapter 8: T4 Code Generation  Chapter 9: Model-First Development Chapter 10: Code-Only Development Chapter 11: N-tier Development with WCF Data Services Chapter 12: Performance Tuning and Exception Handling Chapter 13: Data Binding with the Entity Framework

Author(s): Scott Klein
Series: Expert's Voice in .NET
Edition: 1
Publisher: Apress
Year: 2010

Language: English
Pages: 281

Prelim......Page 1
Contents at a Glance......Page 6
Contents......Page 7
About the Author......Page 13
About the Technical Reviewer......Page 14
Acknowledgments......Page 15
The Need for an Entity Framework......Page 17
This Has Been Tried Before......Page 19
So, What Is the Entity Framework?......Page 20
Database-Driven......Page 21
Model-Driven......Page 22
Working with Entities......Page 23
Entity Framework 4.0 Features......Page 25
Plurality Naming......Page 26
Model Browser Improvements......Page 27
Back-End Support......Page 28
Creating an EDM......Page 29
Taking a Database-First Approach......Page 30
Making Generated Object Names Plural or Singular......Page 35
Taking a Model-First Approach......Page 38
Generating a Schema and Database......Page 43
Managing Table Inheritance......Page 47
Taking a Code-Only Approach......Page 48
The Designer Window......Page 51
Model Browser Window......Page 53
Entities......Page 54
Complex Types......Page 56
Creating a Complex Type......Page 57
Foreign Keys and Relationships (Associations)......Page 61
Navigation Properties......Page 62
Mapping Details......Page 63
Lifting the EDM Hood......Page 64
The SSDL Section......Page 66
Association Element......Page 68
The CSDL Section......Page 69
EntityType Element......Page 70
Associations......Page 71
The CS (MSL) Section......Page 72
EDM-Generated Classes......Page 74
Query-Expression Syntax......Page 79
Context......Page 83
Method-Based Syntax......Page 84
LINQ to Entities......Page 85
Entity SQL......Page 90
The EntityClient......Page 92
EntityConnection......Page 93
Immediate vs. Deferred Query Execution......Page 94
Deferred Execution......Page 95
Immediate Execution......Page 96
ObjectStateEntry......Page 99
Tracking and Saving Changes......Page 100
Updating Entities......Page 101
Adding Entities......Page 103
Relational Inserts......Page 105
Deleting Entities......Page 107
Stored Procedures in the EDM......Page 109
The Model Browser......Page 113
What Is an EF Function?......Page 114
Mapping Functions......Page 115
Insert......Page 118
Update......Page 120
Select......Page 121
Using Functions in Queries......Page 122
Relationships in General......Page 125
Relationships in EF 3.5......Page 126
Creating a WinForms Project......Page 129
Adding an Association......Page 132
Looking at XML Differences......Page 133
Understanding Approaches to Foreign Keys in EF 4.0......Page 135
Adding Dependent Objects......Page 136
Manually Setting the Foreign Key Property......Page 137
Setting the Foreign Key Automatically......Page 138
Building the Sample Project......Page 139
Summary......Page 142
Adding a Template Using Visual Studio 2008......Page 143
Installing a T4 Editor......Page 144
Writing Some T4 Code......Page 145
Scoping Your Code......Page 148
Example 1: Running the Project......Page 149
Example 2: Returning Your Computer’s Processes......Page 150
Example 3: Listing Your SQL Databases......Page 151
T4 Templates and the Entity Framework......Page 153
T4 Customization Example......Page 158
Creating a Conceptual Model......Page 161
Creating Entities in the Empty Model......Page 164
Creating Associations and Navigation Properties......Page 166
Saving the Model......Page 167
Creating the Mappings and Database......Page 168
Tables......Page 175
Associations......Page 176
Handling of Complex Types......Page 177
DB Generation Script Customization......Page 179
Getting Started with Code-Only......Page 183
Creating the Data Project......Page 184
Adding References......Page 186
Adding Context and Connections......Page 188
Creating Configuration Classes......Page 189
Testing the Code-Only Model......Page 191
Building the Project......Page 192
Loading Some Rows......Page 193
Connecting the DataGridView Control......Page 194
Running the Application......Page 195
Additional POCO Information......Page 196
Complex-Type Support......Page 197
Change Tracking......Page 198
Finishing the Example......Page 199
Building the WCF Data Service......Page 203
Testing the WCF Data Service......Page 210
Consuming the WCF Data Service......Page 217
Adding the Service Reference......Page 218
Utilizing the Service......Page 222
Updating the Model......Page 225
Checking the Model......Page 229
Stored Procedure Mapping......Page 231
Building an Entity Framework Project......Page 232
Try/Catch Blocks......Page 235
Exception Class......Page 237
Connection Exceptions......Page 239
Query Exceptions......Page 241
EntitySQL Exceptions......Page 242
Creating a New Form......Page 245
Creating Data Sources......Page 248
Adding Code to the Form......Page 252
Adding a Grid Control......Page 254
Getting the Grid to Display Some Data......Page 255
Testing Your Final Grid Implementation......Page 257
Implementing Add Functionality......Page 258
Implementing Save Functionality......Page 260
Adding Some Code......Page 261
Running the Project......Page 262
Displaying Related Detail......Page 264
¦......Page 269
¦ C......Page 270
¦ D......Page 271
¦......Page 272
¦......Page 274
¦......Page 275
¦ N......Page 276
¦ Q......Page 277
¦......Page 278
¦ T......Page 279
¦......Page 280
¦......Page 281