Tag Archives: EF

Getting Started with EF6 Course on Pluralsight


You may think you read that title wrong. Does she mean EF7? No, I actually invested some time into creating a new Getting Started with EF6 course even though EF6 was released about 18 months ago. When EF6 was released, most of what changed since EF5 was the advanced features and usage. I did a course called “EF6 Ninja Edition: What’s New in Entity Framework 6” specifically to cover those additions/improvements. But for the “toes in the water” first look at EF, not much had changed between EF5 and EF6 so the Getting Started with EF5 course remained pretty relevant.

Watch Getting Started with Entity Framework 6

So why Getting Started with EF6 now, when EF7 seems to be around the corner? Well, EF7 is still going to be a while. Even though a “Beta 6” was announced recently, the team has said in a significant way that EF7 Beta 6 is still “very much a preview” of EF7. A pre-release of EF7 is expected in early 2016 along with the release of ASPNET5. But the RTM of EF7 is still further off than that date. And even then, not everyone will be using EF7 right away.

So EF6 will be around for a long time and I decided that it was useful to have a course that addressed Getting Started with EF6 directly including using the latest version of Visual Studio – VS2015.

The first module is an overview which is designed for not just developers but even your managers who may want to have a better understanding of what EF is and how it fits into your overall plans.

I am also committed to creating two more EF6 courses for Pluralsight — also for the sake of being long-term resources. These will consolidate information in the various courses I’ve created about EF3.5 – 6 over the years. One will be an EF6 Fundamentals and the other will be Advanced EF6.

In the meantime, I’ll be updating the “Looking Ahead to EF7” course to reflect the Beta 6 since things have evolved since Beta 3 when I did that course.

Installing EF Power Tools into VS2015

July 2017: something amazing happened! Erik Ejlskov Jensen, the creator of the SQLCe provider Entity Framework as well as the creator of the very popular SQL Server Compact Toolbox extension for Visual Studio, has given us a community version of EF Power Tools for VS2015 and VS2017. Thanks to the tools already being on GitHub, he forked the tools and now we have

EF6 Power Tools Community Edition that you can get via Visual Studio Extensions

Oct 2016 note: There have been over 60,000 hits to this blog post so far. My host is reaping the benefits ($$$). In July, I submitted a pull request to update the VSIX. The PR was finally merged. Now just waiting for the change to show up in the VS Gallery.

TLDR: If you don’t want to do the tasks (even though they are so easy) you can download the updated VSIX I created from here.

The Entity Framework Power Tools extension for Visual Studio has been around for quite some time and is still called a Beta. I cannot live without it’s “View Entity Data Model (Read-Only)” feature which I used to validate my code first models.

But if you try to install the extension into Visual Studio 2015, you won’t find it.

7-25-2015 9-47-12 AM

Checking the extension in Visual Studio Gallery, you’ll see that it hasn’t been updated to install into VS2015.7-25-2015 9-47-49 AM

The fix is nothing more than making it know about VS2015. There are no other compatibility problems that I have experienced. Modifying an extensions installation package (which is just a zip file!) to be aware of another version of Visual Studio is pretty easy. Here are the steps to get the EF Power Tools into VS2015.

Download the extension from the Visual Studio Gallery page.

Find the file

7-25-2015 9-50-13 AM

and change it’s extension to zip.

7-25-2015 9-50-33 AM

Extract the files from the zip file.

7-25-2015 9-53-01 AM

Open the extension.vsixmanifest file in a text editor and find the Supported Products section.

7-25-2015 9-53-25 AM

And copy paste one of the Visual studio elements, changing the version to 14.0. I have the Enterprise version but didn’t bother changing it from Pro here and it didn’t seem to be a problem.

7-25-2015 9-53-47 AM

Now you have to reverse your steps in order to recreate the VSIX file.

Select the files in the extracted folder and zip them. Don’t zip the folder. The files have to be at the root. (Guess how I learned that! Smile ) I named my zip file VSPowerTools15.zip








Rename the file to have the vsix extension.

7-25-2015 9-56-01 AM

Run the file right from here.

7-25-2015 9-56-16 AM


7-25-2015 9-56-22 AM

If Visual Studio was open, you’ll have to restart to get this to kick in.

Also you’ll see Entity Framework Power Tools listed in the installed extensions when you look at the About section of Visual Studio 2015.

I accidentally mistook this for something it was NOT and (embarrassingly) tweeted it. I had forgotten that I had done this for the VS2015 preview. Then I installed VS2015 RTM on top of the preview and that picked up all of the installed extensions. When I saw the power tools listed in About, I thought they had a) finally gotten rid of the “Beta” tag and b) installed automatically with VS2015. When I realized the extension was installed, I uninstalled that and indeed the tool went away. So for anyone who saw that tweet…. sorry! Guilty as charged …

Looking Ahead to Entity Framework 7 on Pluralsight

Pluralsight has published my latest course, a 2.5 hour course about Entity Framework 7 (EF7).

“Looking Ahead to Entity Framework 7”

EF7 is not released yet. It will get released as a “pre-release” along with ASP.NET 5 so that there is a data stack available for projects that target the CoreCLR. Then the team will do a lot more work on EF7 for a full release possibly (wild guess) at the end of 2015. There are a lot of changes since EF7 is begin rewritten from the ground up. Many new features – from things like Batch Updates that we’ve been asking for since v1 to totally new concepts like being able to query and update against non-relational data stores. But there will also be things that do not get carried forward – most notably for some is the EDMX, the designer based entity model.

This course will show you what’s coming, what’s going, demonstrate a lot of the new features (as they are currently …aka the Alpha or earlier versions) and provide guidance about deciding if and when to move to EF7.

Here is an list of the modules:

You can see the more detailed Table of Contents here.

I’ve already gotten some great feedback on the course. My favorite tweet so far was:

“Great info and insight. I don’t know if I’m happier with what’s being added or being removed.”

Check it out and let me know what you think of EF7!

Some Observations While Playing With EF7 Alpha Bits: Current vs On-Hold APIs

You may or may not have caught this important blog post from the EF team about plans for the first RTM of EF7:  EF7 – Priorities, Focus, and Initial Release. In it, EF Program Manager, Rowan Miller explains that for its initial release, EF7 will target ASP.NET 5, ensuring that ASP.NET 5 has a solid data platform to release with. It also means setting aside some of the proof of concept work that the team has been working on for it’s “new platforms, new data stores” initiative. Namely, Windows Store &  Windows Phone and the non-relational providers that the team has been experimenting with are on hold until after the initial RTM of EF7. This does *not* mean that they are being dropped, just delayed so that the team can focus on shipping something usable sooner. Rowan is also clear about the fact that EF7 will not be considered the “go-to” EF version until much later when they’ve brought these other features in as well as forged ahead with more parity with EF6. I recommend that you read that post.

So what does that mean with respect to the source code for EF7 on Github and the current preview Nuget packages of EF?

Note that I have a package source that is pointed to the ASPNET vNext packages which is also where EF7 lives on myget: https://www.myget.org/F/aspnetvnext/api/v2

Also that I have selected PRERELEASE packages:


And using the console, that means always adding the “-pre” parameter after the install-package command (e.g. install-package entityframework –pre).

First, here’s a look at what DLLs were on Nuget prior to the shift


The shift occurred when the nuget packages went from being tagged as alpha to being tagged as RC. Note that these nuget tags do not reflect the state of EF7, but a package naming decision.


Notice that the AzureTableStorage, Redis and SQLite packages are still there but they are from Dec 1, 2014.

Notice the addition of EntityFramework.Core. That’s where all of the core bits are now.  But the entityframework package is still there. You still start by installing entityframework.

The entityframework package has a dependency on entityframework commands and will pull that in and then that forces nuget to also pull in entityframework.core, relational and migrations. You’ll need to explicitly install entityframework.SqlServer or InMemory if you want them. You’ll need at least one of those.

When you install EF7 from the ASPNetVNext package source, when the installation is finished the following HTML page will pop up in Visual Studio:


I have not tried to use the older providers. They are not going to be kept in sync with the moving forward packages. They will get caught up after EF7 has its initial release.

Also, you do have the ability to get at the source code as it was prior to this big shift. Check the “futures” branch on github:


I believe this is a snapshot that was taken prior to the shift.

Unfortunately, it’s not possible to keep all previous versions of packages on MyGet the way it is on Nuget.  You can get a snapshot of the beta2.11514 packages that Rowan Miller set aside for his Connect demos. https://github.com/rowanmiller/Demo-EF7/  That’s not the latest version of EF7 prior to the shift but close.

Just remember, it is all still early early, evolving and changing rapidly.

Some Observations While Playing With EF7 Alpha Bits: EF7-Able Projects

You can’t install EF7 into just any project. Especially now that they are making the shift to focusing on ASP.NET 5 for it’s initial release.

Here are combinations that will work:

(Have not tried VS2012 ..)

Visual Studio 2013

.NET 4.5.1 projects only

Class Library, Client Projects (WPF, Console, Windows Forms), ASP.NET Projects, WCF

Later in 2015, EF7 will return to working with Windows Phone/Store, but for now, none of the relevant projects will host EF7 (e.g. universal apps, PCLs, etc)

Visual Studio 2015

.NET 4.5.1+ projects only

Class Library, Client Projects (WPF, Console, Windows Forms), ASP.NET Projects, WCF

ASP.NET 5 vNext Console & Class Library projects (and yes, the first sounds like an oxymoron)


ASP.NET apps (and if you’re looking for vNext, those are in the templates)


Some Observations While Playing With EF7 Alpha Bits

My first coding foray into EF7 was as a code monkey for Pranav  Rastogi from the ASP.NET team at TechEd Europe where he walked me through converting a simple EF6 app to EF7. (“Entity Framework Now and Later”, my bit starts at about 50 minutes in.) My next EF7 playtime was working through demos created by Rowan Miller (program manager on EF team) that are available here on his github account: https://github.com/rowanmiller/Demo-EF7/.

These demos depend on a snapshot in time of EF7 alpha  (EntityFramework.7.0.0-beta2-11514)  and demonstrate using EF7  & SQLite in a Windows Phone and Windows Store app as well as against a non-relational database (in this case Azure Table Storage). It also demos some other new features like batched updates, improved LINQ queries and more.

I used these same demos for a conference presentation which meant I practiced them repeatedly and modified them a bit to make sure it flowed in the way I preferred.

The bits are evolving rapidly. I’ve since been reading and writing about EF7 and played just a little but now I’m starting to have my most fun which is asking myself “what happens if I do X? what happens if I do Y?”, debugging, comparing and contrasting behaviors.

With the caveat that EF7 is still alpha and things are still evolving and shifting, I wanted to share some observations as I am playing with it.

1) InMemoryStore Before Committing to a Data Store

When you do any interaction with the DbContext even if you are not trying to query or save data, EF7 still wants you to specify the data provider in DbContext configuration.  Since I’m not yet interested in actually hitting a database, the new InMemory provider is the perfect foil!

In DbContext, I can install the entityframework.InMemory package then specify in my DbContext class that this is the provider I want to use and then I’m good to go.

protected override void OnConfiguring(DbContextOptions options)

I’d used InMemory for unit tests already but I was just using a simple console app to fiddle around EF7 with. That’s still testing, and that’s what the InMemory provider is for – testing.

What I’d like to do is be able to switch the context on-the-fly to use in memory store so I can have a single defined context with all of it’s dbsets, mappings etc and switch it easily to use my real data store or the InMemory store. So in a test project, I’d be able to say “use the context, but for these tests, use the InMemory store”. I see notes on github that this is a goal – e.g. specify provider along with connection string in a configuration file.

Rather than an enormous blog post, I’ll just publish this first bit and add more in bits and pieces …kinda how EF7 is being built anyway. Smile

EF6 Ninja Edition Course is Live on Pluralsight

It’s been a long haul and a long wait. I started work on this course, then switched gears to work on the Domain–Driven Design Fundamentals course with Steve Smith. When I returned to work on the EF6 course, a number of minor releases and patch releases had been published so I had to revise much of what I had already recorded, edited and produced.

But today, finally, the full course has been published on Pluralsight.

Entity Framework 6: Ninja Edition
– What’s New in EF6

It is a little over 7 hours long. This is what I would have done had I written another huge book. So if you are looking for my next book, just watch this course! And you can go back to it for reference.

If you don’t have a Pluralsight subscription (and honestly, the $29 monthly fee if you were to just subscribe to watch this course, is less than those huge books), send me a note and I’ll send you a code for a trial. You’ll probably realize quickly that you want a subscription though to continue accessing the enormous library.

Course Description

Entity Framework 6 brings major improvements to EF that allow developers to align their data access with advanced software practices. The biggest news for EF6 is that it is open-source and has gained a lot from developer community input. Features with broad appeal such as stored procedure mapping in code first, support for the Async/Await pattern when executing queries and commands, simpler patterns for unit testing, and built-in database logging capabilities have gotten a lot of visibility. EF6 is now very extensible with custom Migrations, custom mapping conventions, and the introduction of Dependency Injection patterns to open up low-level DbContext configuration. There are new methods and properties that allow simpler and smarter coding patterns. Rather than present a high level list of the new features, this course dives into each new feature in EF6, ensures that you understand not only what it is for, but how it works, scenarios where you can benefit from it, and gotchas you should watch out for. This course provides a comprehensive look at what EF6 adds to Entity Framework, and it will leave you with the ability to truly benefit from all of the Ninja power that’s been added to this version of EF.

Course Outline

Overview of What’s New in EF6


What Is Entity Framework?

What’s in This Course?

What’s in This Module?

A Brief History of Entity Framework

Why EF6?

A Lap Around EF’s CodePlex Site

Overview of Changes to the EF Designer

Overview of New Features

What’s Not (Yet) in EF6



Getting to EF6


In This Module

Getting EF6 Into New and Old Projects

Updating Projects to EF6



Performance and Stability Improvements


In This Module

Faster Processing of LINQ’s Enumerable Contains

Faster Mapping View Generation

Using nGen to ‘Pre-JIT’ EF6 Assembly

Reuse Open Database Connections

Create DBs That Are More Scalable and Less Prone to Deadlocks

Connection Resiliency for Transient Database Connections

Digging into the Connection Resiliency Feature

Quick Review


Changes to the EF Tooling


EF Designer History

In This Module

EF Designer’s New MSI Installer

Creating a Code First Model From a Database in the Designer

Database Views in Your Code First Model

Customizing the Code First Designer Templates

Refactoring the Generated POCOs and Model

A Warning About a Naming Conflict With Code First From Database

What Does the Empty Code First Model Wizard Do?

Comparing the Code First Model Wizard to the EF Power Tools

Using EF4 or EF5 With the New Designer

A Notable Change to the Model First Workflow

Why You Still Need the EF Power Tools

Quick Review


Stored Procedure Mappings for Code First


In This Module

Understanding EF Stored Procedure Mappings

Visualizing Stored Procedure Mappings

Differences Between Designer-Based and Code First Model Mappings

Conventions for Procedures Created by Code First

Customizing Mappings to Work With Existing Stored Procedures

Quick Review


Custom Code First Conventions


In This Module

Custom Code First Conventions: Why Would You Want Them?

Custom Conventions Basics With Lightweight Conventions

Using Attributes to Specify Custom Conventions

Encapsulating Custom Conventions

Understanding and Controlling Execution Order

Model-Based Conventions

Extending Existing Conventions

Quick Review


More Code First Goodies


In This Module

Database Index Support in Code First

Adding Indexes With Fluent API

Setting the Default Database Schema

Using AddFromAssembly to Load Conventions and Configurations

Understanding and Fixing How Code First Pluralizes Table Names

Using a PluralizationService to Localize Non-English Table Names

Implementing a Custom Pluralization Rule in Your Data Layer

Mapping to Results of Table Value Functions and Stored Procedures

Quick Review


Enhancements to Code First Migrations


In This Module

Affecting the Schema of the Migrations History Table

Smarter Migrations With Idempotent Scripts

Limitations of Existing Migrations Methods

How Migrations Get From Method to SQL

Create Custom Migrations for Other Database Operations

Why HasColumnAnnotation and HasTableAnnotation?

Implementing a Simple Table Annotation

Implementing More Complicated Annotations

Performance Tweak for MigrateDatabaseToLatestVersion Initializer

Migrate From Multiple Models to a Single Database

Using HasDefaultSchema and ContextKey for Multiple Model Support

Easier Migrations for Multiple Models in a Single Project

Combining Database Initializers and Migrations

Quick Review


Improved Database Interaction


In This Module

Simple Database Logging With the Log Property

Tweaking the Log Functionality

SQLCE Functions for LINQ Queries

Introducing the Async EF6 Methods

Demonstrating the Effect of Asynchronous EF6 Methods

Perception and Performance: Load Testing With Async EF6

Quick Review


Code-Based DbContext Configurations and Interceptors


Why DbConfiguration?

In This Module

Creating and Triggering a DbConfiguration Class

Why Move Config File Settings to Code?

Moving Connection Factory to DbConfiguration

Moving Database Initializers to DbConfiguration

The New NullDatabaseIntializer

Provider Services and DbConfiguration

Tap into the Pipeline With Interceptors

Beyond the Interceptor Basics

What Stops Does the DbCommandInterceptor Make in the Pipeline?

Building an Interceptor for Database Logging

Using Interceptors to Solve Complex Problems

Understanding the Role of Dependency Resolution

Hosting DbConfiguration in External Assemblies

Quick Review


Sometimes It’s the Little Things


In This Module

EF6 and Mocking Frameworks

Writing Tests to Mock Methods Like DbSet.Find

Writing Tests to Mock LINQ Queries

Nested Entities and Complex Types

Fixing the Ambiguous Types Problem

Custom Equals vs. Change Tracker Equals

Smarter LINQ to Entities Queries

Yes, You Can Haz Changes With HasChanges

Quick Review


My TechEd Europe Schedule


TEEU_2014_I’m speaking_1I’m so very excited to be heading to Barcelona shortly for TechEd Europe. You may or may not be aware of my dashed hopes last year when I was scheduled to speak at TechEd Europe in Madrid. But when I found myself stuck in the Chicago O’Hare airport on my 2nd day of travel, only to be told I wouldn’t get to Madrid until Thursday afternoon (after 4 days of travel) it was time to turn around and go home. I also had scheduled a post event side trip to Barcelona – this too, I canceled.

I was a little surprised that TechEd was willing to try again considering my bad history but I will be speaking at the 2014 version of the event.

Not only am I looking forward to my first ever trip to Spain and the amazing city of Barcelona, but it will be my first opportunity to meet so many developers that I’ve never met before.

My Session

My talk is on Friday, Oct 31 at 12-1:15pm. Yes, on Halloween!

Entity Framework Model Partitioning in Domain-Driven Design Bounded Contexts
Bounded Context is one of the most critical patterns in Domain-Driven Design (DDD). While you shouldn’t have to worry about your data persistence while you are modeling your domain, it is still worrisome to follow DDD patterns not knowing how you’ll get your ORM to fall in line when it’s time to implement the data layer. Entity Framework sample solutions have a long history of creating one huge model to map to one huge database to satisfy all of the needs of your application. In this session we look at patterns using Entity Framework that will support not only multiple bounded contexts in your software but even those areas that are satisfied with pure CRUD logic. You also see patterns to bridge the divides between those bounded contexts when implementing the data persistence with Entity Framework.

Getting the Most Out of My Session

Dino Esposito will be doing a relevant talk on Tuesday that will be useful if you are new to Domain-Driven Design.

DEV-B211 Architecting and Implementing Domain-Driven Design Patterns with Microsoft .NET  Tuesday, October 28 1:30 PM – 2:45 PM Room: Hall 8.1 Room G

I’d also recommend watching the Domain-Driven Design Fundamentals course that Steve Smith and I created for Pluralsight. It’s about 4 hours long and is a great first look as well as a refresher on some of the key concepts of DDD. You’ll definitely get a lot more out of my talk if you’ve seen this in advance. If you don’t have a subscription to Pluralsight, send me a note and I can get you a 30 day trial code.

Where to Find Me

Here is my current schedule. This does not list talks I plan to attend, but the opportunities I will have to meet people and geek out! Smile


So much bling, I just can’t choose!

TEEU_2014_I’m speaking_4TEEU_2014_I’m speaking_1TEEU_2014_I’m speaking_3

What About EDMX When EF7 Arrives?

I’m getting a lot of folks asking me about the announcement that EF7 will focus on code first and there will be no support in EF7 for designer based EF models.

I’ll give my two cents, even though I do think the EF team has been pretty clear about this in both their blog post about EF7 plans 

EF7 – New Platforms, New Data Stores

and in Rowan Miller’s TechEd talk where he devoted the last 20 minutes to early look at early bits and early thoughts about EF7

Entity Framework: Building Applications with Entity Framework 6

Here’s the scoop: EF6 and the designer will continue to be available and worked on but the big effort will go into EF7 going forward. Personally, I can’t promise it will be around 10 years from now so please don’t bang down my door in 2024.

I’ve also been asked: “should I bother learning about the EDMX since it will not be in EF7?” I firmly believe that learning a bit about modeling via the designer helps get some of the concepts across for if/when you do code first modeling.

Also don’t forget about some of the 3rd party tools that provide designer support such as LLBLGenPro, Huagati Tools,  and DevArt’s Entity Developer. I’m guessing they will be moving their tools forward, though I haven’t looked into it yet.

Some DDD+EF Resources

Could not fit this into a tweet in response to a request.

Here are some resources for how EF can be a partner to a Domain Driven Design world:

Update June 2015:

Microsoft Ignite, Chicago May 2015
Domain-Driven Design for the Database Driven Mind (90 minute presentation video on Channel 9)

Update: October 2014:

MSDN Mag Oct 2014 Issue:
Data Points: A Pattern for Sharing Data Across Domain-Driven Design Bounded Contexts
Julie Lerman explores a way to mirror data as one scenario for sharing data across DDD bounded contexts.

MSDN Mag Dec 2014 Issue:
Data Points: A Pattern for Sharing Data Across Domain-Driven Design Bounded Contexts : Part 2
(will provide link when available)

Video: Oredev, Fall 2013 (by me)

Video: TechEd North America, May 2014 (Vaughn Vernon)
How You Can Implement Aggregates and Domain Entities Effectively in Domain Models, with .NET

Article Series:
MSDN Magazine Data Points Column (by me) Aug, Sept & Oct 2013
Coding for Domain-Driven Design: Tips for Data-Focused Devs, Part 1
Coding for Domain-Driven Design: Tips for Data-Focused Devs, Part 2
Coding for Domain-Driven Design: Tips for Data-Focused Devs, Part 3

Domain modeling with Entity Framework Scorecard (Jimmy Bogard)

Bonus for NHibernate Converts:
And for those who are looking for this by way of moving from DDD + NH, Jimmy Bogard did a great post (with pointers to related posts) on Migrating from NHibernate to EF.