Supplemental files and examples for this book can be found at http://examples.oreilly.com/9780735664166-files/. Please use a standard desktop web browser to access these files, as they may not be accessible from all ereader devices.
All code files or examples referenced in the book will be available online. For physical books that ship with an accompanying disc, whenever possible, weve posted all CD/DVD content. Note that while we provide as much of the media content as we are able via free download, we are sometimes limited by licensing restrictions. Please direct any questions or concerns to .
Introduction
Gaining access to data in a managed way without a lot of codingthats a tall order! The Entity Framework fulfills this promise and far more. Each version of the Entity Framework is more capable than the last. The latest version, Entity Framework version 5, provides you with access to far more database features with less work than ever before, and Microsoft ADO.NET Entity Framework Step by Step is your gateway to finding just how to use these phenomenal new features. In this book, you get hands-on practice with all the latest functionality that the Entity Framework provides. By the time you finish, youll be ready to tackle some of the most difficult database management tasks without the heavy-duty coding that past efforts required.
Fortunately, this book doesnt get so immersed in high-end features that it forgets to tell you how to get started. Unlike a lot of tomes on the topic, this book starts simply and helps you gain a good foothold in understanding just why the Entity Framework is such an amazing addition to the your developer toolbox. Youll see examples where the automation does just about everything for you with little coding required, and yet you obtain professional-looking results. In fact, thats what youre buying with the Entity Frameworka reliable means of creating code quickly and successfully without the problems that would ensue if you tried to create the same code completely by hand. The books 44 examples help you gain experience using the Entity Framework in a hands-on environment where you actually create code, rather than just reading about what might work.
Of course, you do eventually delve into higher-end topics. Youll find an entire chapter on one of the most requested features, Table-Valued Functions (TVFs). Access to this feature alone makes the upgrade to Entity Framework 5 a significant one. Youll also discover how to handle performance problems and perform low-end tasks such as using inheritance when creating a model. In short, by the time you finish this book, you will have the experience required to handle every common task that developers need to know how to perform.
Who should read this book
Anyone who creates database applications using ADO.NET and is tired of writing reams of code will definitely benefit from reading this book. What you should ask yourself is whether you want to become more productive while writing code that is both more reliable and better able to interact with the database. Although the coding examples are written in C#, several Microsoft Visual Basic developers tested this book during the writing process and found that they could follow the examples quite well. All you really need is a desire to write database applications more quickly and with less fuss.
Assumptions
To use this book successfully, you need a good knowledge of database programming concepts using a technology such as ADO.NET. Although every attempt is made to explain basic (and essential) topics, a knowledge of working with databases using the .NET Framework will make working through the examples significantly easier.
You also need to know how to write applications using the C# programming language. All of the examples are written using C#, and there isnt any attempt to explain how the language elements work. If you dont have the required C# knowledge, you should consider getting John Sharps Microsoft Visual C# 2010 Step by Step (Microsoft Press, 2010).
Some of the examples also require some knowledge of Transact-Structured Query Language (T-SQL). Again, there are plenty of comments provided with the various scripts, but there isnt a lot of additional information provided about language elements. The book assumes that you know how basic SQL queries work.
Who should not read this book
This book is most definitely not aimed at the complete novice. You must know a little about both SQL and ADO.NET to work with the book successfully. In addition, you must know the C# programming language fairly well. The examples in the book focus a little more on enterprise developers, but hobbyists should be able to follow the examples without problem. If youre looking for a high-end book with lots of low-end programming examples and no hands-on techniques, this is most definitely not the book for you. This book is all about getting people started using the Entity Framework in a meaningful way to perform most common tasks, which means it uses several different techniques to convey information so that a majority of readers can understand and use the material presented.
Organization of this book
This book is organized into five parts. Each part is designed to demonstrate a particular facet of the Entity Framework, with an emphasis on the functionality provided by version 5. Here is a brief overview of the book parts (each part introduction has more detailed information about the content of the chapters in that part):
. This part of the book introduces you to the Entity Framework version 5. Youll discover what is new in this version of the Entity Framework and also basic concepts such as the parts of a model. Unlike many other texts, this part also tells you about the three workflows available when working with the Entity Framework: model first, database first, and code first. Every chapter includes coding examples that emphasize the basics so that you can see precisely how the Entity Framework works at a basic level.
. Once you have a basic understanding of what the Entity Framework does and why youd want to use it, its time to see how to perform basic Create, Review, Update, and Delete (CRUD) operations. This part of the book provides an essential discussion of how to perform essential tasks with full automation in place. Its the part of the book you want to read to emphasize speed of development over flexibility in accessing database functionality.
. Most applications require more than a display of raw database data and simple CRUD operations. This part of the book takes the next step in your journey of actually controlling how the data appears and precisely what data is retrieved from the database. You discover two client-side techniques for manipulating data (Language Integrated Query [LINQ] and Entity Structured Query Language [Entity SQL]). In addition, you see how to use server-based techniques that include stored procedures, views, and TVFs.