Scott Hanselman

Entity Framework Magic Unicorn (and much more!) is now open source with take backs

July 19, 2012 Comment on this post [25] Posted in Data | Open Source
Sponsored By

The Unicorn is fineAlmost exactly two years from the day we announced Entity Framework "Magic Unicorn Edition" and just a few months after open sourcing of ASP.NET MVC 4, ASP.NET Web API, and Razor we're happy to announce we will release the source code for the Entity Framework under an open source license as well!

This is cool for a number of reasons. The EF team is continuing to move forward with a commitment to transparency. The community will be able to not only watch the check-ins and monitor the progress of the project, but also get involved themselves, submit pull requests for bug fixes, use daily builds and give feedback much more efficiently.

Just like the open source ASP.NET components and open source Azure SDKs, Entity Framework will continue to have the same full-time Microsoft engineers working on the project and will remain a fully supported Microsoft product that will ship both standalone AND with Visual Studio.

The code being open sourced includes the Entity Framework Runtime and NuGet packages, Code First, the DbContext API, the Entity Framework Power Tools as well as pieces that shipped originally with the .NET Framework. The team is also working to open source the EF Designer surface in the future as well.

By open sourcing EF we open up the design and development process that started the EF 4.1 preview builds. People who are interested can get nightly builds, see the source code changes, and engage in discussion about the design and implementation. The EF team is committed to opening up the development and involving the community and are going to work hard to make that happen.

Entity Framework will live in a Git repository at and you're welcome to follow, fork, discuss and file bugs against it as you see fit. You could fork it just to fix a bug quickly to unblock work that uses EF, or you could create a custom version of EF with different capabilities. Since the changes can also be contributed back this gives people a lot greater flexibility in how they develop with EF.

Again, we've previously open sourced the Azure SDKs, the ASP.NET Web Stack, and now Entity Framework. These products all have the same teams assigned (and in most cases have more resources than before), the same developers coding and the same support guarantees. They are open source projects but they are also supported and released Microsoft products suitable for use in any company. They'll continue to ship with Visual Studio as well as standalone as packages in NuGet. The investment in all these technologies has been significant in the past year and investments will continue going forward with new versions and even more cool features.

Async - My Favorite New Entity Framework feature

Just as an example, I wanted to show a new feature in the upcoming EF6 that the team is hard at work on for release next year. Visual Studio 2012 introduces the Aync and Await concepts that make asynchronous code much easier to write (and understand). Damian, Levi and I talked about async and the surrounding concepts in this week's Hanselminutes podcast.

EF6 will introduce support for the new task-based asynchronous pattern when querying and saving data. You can actually look in the open source code base today and find the first parts of this feature are already checked in! ;)

As an example, using EF5 you could define a helper method that will find the store closest to a given location. Any code that calls this method would need to wait while it executed.

public Store FindClosestStore(DbGeography location)
using (var context = new StoreContext())
return (from s in context.Stores
orderby s.Location.Distance(location)
select s).First();

But in EF6 it is easy to turn this into an asynchronous method that can be left to execute while the calling code continues on with other tasks.

public async Task<Store> FindClosestStore(DbGeography location)
using (var context = new StoreContext())
return await (from s in context.Stores
orderby s.Location.Distance(location)
select s).FirstAsync();

This is just one feature but it's my favorite. You'll also soon see mapping of Stored Procedures as well as support for custom conventions using the Code First API.

Be sure to follow the Entity Framework Repository and subscribe to the check-ins via RSS to stay up on the latest features and improvements to EF! Also, do go chat directly with the Entity Framework team on Jabbr (powered by SignalR and Azure) in their room:

Related Links

Sponsor: My personal thanks to DevExpress for sponsoring this week's feed! Check out their new stuff, it's amazing! DXperience 12.1 helps you realize your creative vision. Beautiful design and rich user experiences are at the center of the modern development conversation. From iPads to mobile phones, focus on great design. Try Now.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
July 19, 2012 20:10
and the unicorns rejoiced!
July 19, 2012 20:44
Even better would be EF5.1 shipped to NuGet sometime this year with the async support! (The announcements are of course very welcome.)
July 19, 2012 21:10
Wow. I feel like I'm out of the loop. Does this mean that EF can do async database calls now/soon? As in not blocking a CLR thread for the DB call?
July 19, 2012 21:12
July 19, 2012 21:32
Sweet gif
July 19, 2012 22:27
Aync and wait? ;) :D
July 19, 2012 23:16
Impressive, such an important lego block open sourced... Let's do System.Web next, okay? Forget the old mantra "it's part of the core .NET runtime", just do it!

Scott, I know you played a big part in this, well done sir!
July 20, 2012 5:34
My prayers were answered
July 20, 2012 5:50
Would have been muuuuch happier to see a merger w/ NHibernate. The community already has a fantastic ORM framework.

July 20, 2012 10:57
Great news, now its available with licence. Happy :)
July 20, 2012 11:46
Does the loading of multiple entities supports async too?
July 20, 2012 11:51
Interesting that they put this in a Git repo (instead of TFS), but only to then push it to CodePlex (instead of Github)
July 20, 2012 12:32
Indeed very interesting that is is available as a git repository. First commit is 20-03-2012 followed by a big set of changes.

Although it is available on codeplex you can easily put it on github if that works for you.

I just create a repository and added an additional remote and push the repository to it :
July 20, 2012 12:44

That's only interesting if you think git==github, which is false. Codeplex is the main place where Microsoft puts source from the .NET runtime. GitHub is where some related projects get hosted, especially if the project is farther away from core .NET (like Azure stuff for Node.js).
July 20, 2012 15:12
I tried to open the solution in Visual Studio 2010 and its service pack 1. But projects show "incompatible" error for all the projects.. Do I need to open the solution in visual studio 2012 RC?
July 20, 2012 15:36
Where is the batch update/delete feature? Will it ever be? :(
July 20, 2012 17:05
What are the odds that making it "open source" is just a pretense to stop developing it?
July 20, 2012 17:07
Could I make the russian translation of a post in my blog?
July 20, 2012 18:46
Denis - sure

Anonymous - No chance. We released the Azure SDKs, MVC, Razor, WebAPI, and they have more developers than ever. Same with EF. Open Source is the way we're going.
July 20, 2012 22:58
I'm very much a novice at this sort of thing, but what impact would this (possibly) have on providers for other RDBMS other than SQL Server? I know Devart has one, but the tier that actually has EF support for postgre is outside of what I can afford (basically hobby projects with the hope they eventually amount to something on zero budget).
July 21, 2012 1:28
Open source Silverlight, MS is not supporting it normally anyway, so may be it's just a last chance for it to survive.
July 21, 2012 7:51
Slava: open sourcing Silverlight won't happen if you know MS history. WinRT is basically a lightweight fork and MS almost never releases something where even an extremely old version can show you the internals on something they've redone. I'd love to see it happen because that plugin on multiple operating systems would be an extremely useful learning tool.
July 21, 2012 21:57
Andrei Ignat - Yes, we have a ForEachAsync method for iterating over streaming results asynchronously and ToListAsync for getting results of a known size into memory in a single call.
September 10, 2012 23:49
This article:

(where I can't comment because it's too old) Says:

What Changes Can Migrations Detect Automatically?
Renaming a property or class
See ‘Renaming Properties & Classes’ for the additional steps required here

"Renaming Properties & Classes" is not mentioned anywhere else in that post. Nor your blog. Nor the ADO.Net blog. In fact, a google search for that string finds exactly one hit: That blog post, with no further explanation.

How does Migrations handle renaming properties automatically? From what I can tell it does not; it just drops columns and adds columns, losing data in renamed columns without manual intervention. Is there a way to get the above described feature to work?
March 07, 2013 8:34
EF is an overbaked spaceshuttle that has lots of performance problems. It also offers lots of leaky abstractions (you need to understand it's underpinnings to use it). It has a feature for every one and creates as many problems as it solves. Try a micro orm (dapper, massive) and you'll never go back to the EF pig. What do we really need in an orm? For most us it's simply to work with strong types. Check out dapper.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.