Entity Framework Fundamentals

entityframework-large

In this video series, Griff Townsend will show you Data Layer construction and conceptual modeling using Microsoft’s Entity Framework. Through these lessons, you’ll not only get experience in building an Object Relational Mapping, you’ll also be engaged in an architectural discussion of layered application models. A school database is used as our guide in building, querying, and implementing the Entity Framework in WinForms, WPF, ASP.Net, ASP.Net MVC, and ADO.Net Data Services.

This series is organized into 3 days’ worth of material:

Jump To …

Day 1

EF301_01_01 – Entity Framework Overview & Concepts

Entity Framework Overview & Concepts. In this topic Griff introduces the Entity Framework, along with the Conceptual Schema, Storage, and Mapping Definition Languages. Using the provided SQL, you will create a school database and build a simple, queryable model using C# classes that map directly to the underlying database.

EF301_01_02 – Configuring Entities

In this video, we look more closely at modeling both simple and complex types in the Entity Framework. We will take an in depth look at the Conceptual Schema Data Language, and build our complex types using the EF command line tool EdmGen.exe. We also examine the nature of EF and how we can customize our Entities with properties derived from types not supported directly by EF (enums, for instance).

EF301_01_03 – Establishing Relationships

One of the advantages of using an automated relational mapping tool like EF is its ability to maintain and simplify relationships between objects in a more object oriented manner than what is stored in the database. This video will explore the supported relationship types in Entity Framework, how they work, and how we navigate the data model and Load relationships on demand.

EF301_01_04 – Entity Inheritance

Data models in EF can also take on a more truly Object Oriented structure through the use of abstraction and inheritance. We further refine our school model by adding inheritance to School courses and departments. Both Table per Type and Table per Hierarchy samples are presented.

Day 2

EF301_02_01 – Object Services Overview and Using the ObjectContext

Object Services Overview and Using ObjectContext. Where the first lesson focused on building simple and complex Entities from our data model, Lesson 2 looks at the basic CRUD (Create, Read, Update, and Delete) that happens during the lifetime of our application. In this video, Griff begins with a review of the Entity Data Model architecture, then introduces us to the role of Object Services and the ObjectContext class.

EF301_02_02 – Querying Entities

It’s very difficult to edit data that we don’t have, so our first step in working with Entities is to query the ObjectContext. Griff outlines EF querying techniques such as eSQL, the custom SQL syntax developed directly for EF; building reusable compiled queries with the ObjectQuery class, and LINQ to Entities (some familiarity with LINQ is assumed).

EF301_02_03 – Create, Update, and Delete

Now that Reading is out of the way, Griff takes us into true editing mode through our ObjectContext. You’ll be surprised at how easy it is to get started with EF editing and the flexibility it extends in editing the underlying data store. The editing samples that we use in this session serve as a launching pad for our next Lesson.

Day 3

EF301_03_01 – Binding to WinForms and WPF

Now that we’ve looked at both the data- and logic- layers, it’s time to take a look at how we can interact with the Entity Framework in our presentation-layer (the UI). First, we use WinForms and the ObjectDataSource. Then, Griff shows how simple it is to use EF in the Windows Presentation Foundation (WPF).

EF301_03_02 – EF in ASP.Net

In this video, Griff builds a web interface for the school database using both the Entity- and ObjectDataSources against a list view control. Data templating, binding, and object peeking are used for display and editing in the web environment.

EF301_03_03 – MVC and EF – an ideal match!

Isn’t it great when two technologies work well together? Such is the case with the Entity Framework and the ASP.Net Model View Controller implmentation. In this video, Griff provides an introduction to MVC (see our excellent Hands On ASP.NET MVC tutorials for an even more indepth look), then walks through building an application for viewing, adding, editing, and deleting student information from the school database.

EF301_03_04 – The ADO.Net Data Services Framework

While working with a traditional User Interface can be a lot of fun, a growing trend in development has been the extension of another kind of interface: interaction with the data itself. In this video, Griff walks step by step in building a RESTful service for our applications using ADO.Net Data Services (v1 and 1.5 are covered), then shows the steps necessary to use ADO.Net Data Services in the WPF application covered in Lesson 3-1.