About the book
Title: Microsoft Entity Framework in Action
Publisher: Manning Publications
Chapters: 19 + 2 Appendices | ~500 pages
Authors: Stefano Mostarda, Marco De Sanctis, Daniele Bochicchio
Overall rating: 9.24 out of 10
This book was in Manning Early Access Program (MEAP) while writing this review. I reviewed a draft released on 12th August 2010. This is a detailed review where I rate each chapter and describe it’s contents. The overall rating mentioned above is the average of all chapters’ ratings.
I highly recommend this book. No further knowledge about Entity Framework is required. So you don’t have to know anything about EF1 in order to read and gain benefit of this book. Great effort spent on this book by the authors and the publisher. You’ll get a great value with reasonable amount of money compared to the information provided in this book.
Book description –as stated in the book page–
Microsoft Entity Framework in Action introduces the Entity Framework to developers working in .NET who already have some knowledge of ADO.NET. The book begins with a review of the core ideas behind the ORM model and shows how Entity Framework offers a smooth transition from a traditional ADO.NET approach. By presenting numerous small examples and a couple larger case studies, the book unfolds the Entity Framework story in clear, easy-to-follow detail. The infrastructure and inner workings will be highlighted only when there's the need to understand a particular feature.
Microsoft Entity Framework in Action at glance
The Book is divided into 4 parts consisting of 19 chapters plus 2 appendices making around ~500 pages in the draft I reviewed. The book is very well organized. Its chapters follow good sequence where each chapter and each section hands you to the next one smoothly, making the flow of knowledge and ideas well organized in your mind.
Chapter 01 - Data Access reloaded: Entity Framework (free for download, visit the book page)
This chapter is very important if you are new to O/RM world.
The chapter shows how relational database engines became more powerful in terms of features available to developers. And that relational databases are optimal to store data while objects are best way to represent them in applications as OOP allows a better coding style which ease the development.
Discussing classic ADO.Net data access way using DataReader and DataSet and challenges of being bound to the database structure. And the role of ORM in general in resolving Object/Relational mismatch problems and that it places itself between the application code and the database taking care of object persistence to the underplaying data store.
Showing the differences between the 2 worlds (relational databases Vs. objects) and how objects are used to represents data stored in database. And how Entity Framework plays its role as an ORM aiding developers to solve the mismatch between the paradigms and offering a convenient way of accessing data.
The chapter introduces Entity Framework as a free ORM choice part of .Net 4.0. Giving quickly overview on its architecture and design elements describing the role of each of those elements.
By the end of this chapter, you will have a strong knowledge of what an ORM is, what is it used for and why you should always think about it when creating an application that works with a database.
Chapter 02 - Getting started with Entity Framework
This chapter starts clearly describing the sample application requirements being used across the book. Then moving through different options available to design the application using Entity Framework exploring different inheritance models supported by entity framework.
A detailed walkthrough on how to build your entity model using Entity Framework using VS2010 describing and explaining different aspects clearly focusing on Entity Framework capabilities as powerful ORM. Showing 2 different approaches to build applications using Entity framework using Database First and Model First.
Many Entity Framework basic stuff introduced here including entities and entity sets, complex types, inheritance models and how to work with Entity Framework designer through a detailed walkthrough tutorial. The chapter also introduces the basics of CRUD operations using Entity Framework.
Chapter 03 - Querying the model: the basics
This chapter is about the basics of the most basic thing of Entity Framework: querying. You'll learn about different ways of querying with Entity Framework. In particular, you will learn how the Object Services layer enables you to query the database and which other components collaborate with it. It also shows how change tracking is managed through object services.
What's more, you will understand how to discover the SQL generated by Entity Framework so that you can decide whether use it or handcraft a custom SQL command. By the end of this chapter, you will understand what happens under the covers and the theory behind querying.
Chapter 04 - Querying with LINQ to Entities
This chapter is about how to do queries using LINQ to Entities showing how to do filtering, projection, sorting and grouping. It also explores how to execute normal T-SQL queries.
The chapter describes new LINQ to Entities features supported in EF4 and weren't in EF1 such as using of Contains method.
The chapter explains clearly how to do filtering with single associations and collection associations. It also walkthrough how to do paging on entities using LINQ to Entities.
The chapter is like a journey on LINQ to Entities. Exploring different kind of LINQ extensions supported in LINQ to Entities covering set & aggregation methods.
You'll also learn about different loading strategies (Eager loading, lazy loading and manual deferred loading)
Chapter 05 - Domain Model Mapping
The chapter started with a very nice quote "a strong knowledge of the Entity Data Model and model classes code is fundamental to really master Entity Frame". And this is what this chapter is about, it strength your knowledge about Domain Modeling & EDM with Entity Framework. This chapter covers mapping of tables or view to entities. Showing almost everything about EDM and manual mapping describing XML elements used by EDM.
Walking through how to build EDM files (CSDL, SSDL & MSL) manually. To give you better knowledge about EDM and XML elements form it.
Finally the chapter highlights that you can do customization in EDM. This could be useful to add validation to your model.
Chapter 06 - Understanding entity lifecycle
This chapter is about entity lifecycle and change tracking of entities. And how entities are transformed from one state to another.
You’ll lean about how states can be changed for an entity showing that entity state is managed by its context and can be controlled by the developer. There is a good figure on this chapter showing the states of an entity and what context methods make it change.
The chapter talks about the internals of entity change tracking which actually gives you a strong knowledge about how Entity Framework manage this. This is a very big plus for the book and this chapter.
Chapter 07 - Persisting objects into the database
Explore how to persist modification to the database (insert, update & delete) in both connected and disconnected scenarios. So you’ll learn more about the 2 different scenarios.
Lean how to do persistence of single object and complex object graph.
The chapter at the end shows how to deal with exceptions highlighting UpdateException instance thrown when an exception occur when persisting changes using EF. Also it highlights how to execute custom commands using EF.
Chapter 08 - Handling concurrency and Transactions
Learn about concurrency problem and how it can be managed using Entity Framework. Walking through different solutions for concurrency problem, pessimistic approach & optimistic approach. Showing pros and cons of each approach.
The chapter shows that EF only support optimistic concurrency. And how it's applied on entities with relations and inheritance. The chapter introduces you to TransactionScope class. Also explains the transactional ObjectContext.
Chapter 09 - An alternative way of Querying: Entity SQL
It's all about Entity SQL and why it's important comparing it with it's alternative LINQ to Entities. Walking-through Entity SQL History provide you with a solid knowledge about the origin of this language.
The chapter is going through Entity SQL shows the differences between Entity SQL language and the known T-SQL. Exploring different options available in Entity Framework to execute Entity SQL query.
Learn how to do filtering, projection, sorting and grouping with Entity SQL as you did with LINQ to Entities. You'll also learn about query builder methods in EF
The chapter unleash the power of Entity SQL showing when it can be much more powerful than LINQ to Entities
Chapter 10 - Working with stored procedures
This chapter shows how to interact with stored procedures using Entity Framework to perform data retrieval and persistence. Walking through importing stored procedures into your EDM using EF Designer in VS2010 as well as manually showing you how to do mappings manually in EDM.
Chapter 11 - Working with functions and views
Learn how to build model views in your EDM using Defined Queries; a hidden gem in Entity Framework.
Learn about Database functions and UDF -user defined functions-, how can you import them in your model and use them in your queries.
Learn about Model defined functions, what are they, how to create them and use them in your queries, both Entity SQL and LINQ to Entities queries.
Learn about tricks to over come some limitation shown in chapter 10 about mapping data returned from stored procedures to complex properties in your entity.
Chapter 12 - Exploring EDM metadata
Learn about how to access your model EDM metadata using APIs why you might need to do such thing?
Learn different ways to access EDM metadata, moving step by step to get your MetadataWorkspace instance ready to work with.
Learn how to access different EDM schemas (CSDL, SSDL) as well as your entity classes using MetadataWorkspace.
Put what you've learnt all together to build and EDM Metadata Explorer.
Chapter 13 - Customizing code and designer
Learn about VS Code generation templates built with T4. The chapter will teach you the basic of T4 code.
Understand the code generation template provided by Entity Framework team that supports POCO to be able to modify it.
Learn about VS2010 extension Entity Designer Database Generation Power Pack tool and how it can used to do assist you in Model First scenario. Leaning behind the scene of how the generation process of the DDL is performed through workflow foundation activities and T4 templates.
Chapter 14 - Designing the application around Entity Framework
Learn how Entity Framework can be used to build application using Domain Driven Design and the design artifacts of DDD and where can Entity Framework fits on each layer.
Chapter 15 - Entity Framework and ASP.NET
The chapter requires knowledge of building web applications using ASP.Net. And be familiar with ASP.Net Data Controls and Data Source Controls
Chapter 16 - Entity Framework and N-Tier Development
Learn about N-Tier architecture and it's challenges and how to use Entity Framework with WCF services to build services using entities.
Learn different approaches to build service-oriented application using Entity Framework exploring pros and cons of each approach
Learn about Self-Tracking Entities, the Entity Framework proposed solution for N-Tier architecture and its pros and cons.
Chapter 17 - Entity Framework and Windows applications
Learn how to adapt your entity classes to participate in data binding in desktop applications and what pattern to follow to take the best out of windows forms/WPF applications .
Learn about how to put code generation learnt in chapter 13 in action to implement data binding aware entities.
Walkthrough on how to build a windows forms application that uses Entity Framework with data binding facilities
Walkthrough on how to build a WPF application that uses Entity Framework with data binding facilities
Chapter 18 - Testing ADO.NET Entity Framework
This chapter introduces the concept of Unit Testing while teaching you the basics of writing unit tests using MSTest in VS2101.
Learn about how to isolate your code under test from external dependencies in your unit tests
Learn about Mocking frameworks and how you can use one to fake dependencies used in your code under test.
Learn about integration testing with direct interaction with database to validate your Entity Framework based repository persist and retrieve data correctly.
Chapter 19 - Keeping an eye on performance
A study on the performance of Entity Framework comparing it with classic ADO.Net way of accessing data. You are going to build an application to evaluate and compare performance of both Entity Framework and classic ADO.Net
Learn about different ways to enhance the performance of Entity Framework based data access.
Learn about how boost the performance of your LINQ to Entities Queries using Compiled Queries.
Learn about how enhance the performance of your Entity SQL using plan caching.
There are 2 appendices in this book, Appendix A is about the basics of LINQ. You should read this Appendix if you are not familiar with LINQ and before starting chapter 03.
In Appendix B is about Tips and Tricks when working with Entity Framework. You should read after you finalize the book if this is your first time to learn about Entity Framework. Don’t miss it!
I highly recommend this book. It’s well written and organized. It does it’s goal by delivering high quality education materials on Entity Framework.
I hope you enjoyed this review.