Editor's Note - In Praise of Entity Framework 6
By Michael Desmond | December 2013
There’s a reason that Julie Lerman’s Data Points column is consistently among the most widely read in MSDN Magazine. In addition to being a whip-smart programmer with a keen sense for what developers need, Lerman covers that most core and enduring aspect of programming—managing data. Development platforms come and go, but the challenges of wrangling data always remain.
Which is why this month’s issue of MSDN Magazine leads off with a feature on Entity Framework 6, the latest version of the Microsoft-founded, object-relational mapping (ORM) framework. Lerman took a break from her usual column-writing schedule to pen the feature, titled “Entity Framework 6: The Ninja Edition”. As Lerman points out in the article, Entity Framework 6 represents a major step forward from Entity Framework 5, boasting improved performance, reduced complexity and features that allow for more advanced development scenarios.
Notably, the latest version of Entity Framework was developed under an open source development model and has been decoupled from the long release cycles of the Microsoft .NET Framework. As Lerman reports, the Entity Framework APIs have been extracted from the .NET Framework, allowing timely updates and enabling compatibility with both .NET Framework 4 and 4.5. Microsoft also disentangled the Entity Framework 6 Designer from Visual Studio, casting it as a Visual Studio extension that the Entity Framework team is able to update independently of Visual Studio updates. You can find the project hosted on CodePlex at entityframework.codeplex.com.
“I think one of the most important things about EF6 [Entity Framework 6] is the fact that it’s now completely open source,” Lerman says, noting the contributions of developers like Unai Zorrilla, whose AddRange and RemoveRange APIs streamline the addition and removal of multiple entities in Entity Framework 6.
Many developers are familiar with the major features of Entity Framework 6, such as support for asynchronous querying and saving, and support for stored procedure mapping in Code First models. But Lerman says a host of smaller, less-publicized changes can really impact development. Two examples she points out are the ability to combine calls in a shared DbTransaction and the ability to reuse opened database connections.
“Some bigger features are getting a lot of airplay. But there are so many other smaller ones that may not be used by as many developers but will have a big impact for those who do use them,” Lerman says.
While Entity Framework 6 has delivered many improvements, Lerman says she’s looking forward to a few capabilities that didn’t make it into the latest version of the framework. Key among them is better tooling for reverse engineering to Code First classes and DbContext, which Lerman says will make it easier to start with an existing database and create constrained models used with Domain-Driven Design (DDD) architectural patterns.
I asked Lerman to tell me why a developer wouldn’t want to consider moving up to the latest version of Entity Framework. She was direct.
“As long as the Entity Framework provider you’re using has been updated to be compatible for EF6, I can’t think of one. Even if you’re using .NET 4, EF4, EntityObject and ObjectContext, other than some namespace changes, you really don’t change any code. You can move to EF6 and benefit from the faster view generation, and even take advantage of some of the new features like reusing open DbConnections,” she explains. However, she cautions that developers should do some testing before jumping into that scenario.
There’s a whole lot to like in Entity Framework 6, and Lerman’s feature on the new ORM tool is well worth a read for those hoping to take advantage of it.
Michael Desmond is the Editor-in-Chief of MSDN Magazine.