Data Driver

Blog archive

EF4 Beta 2 Arrives with New Features

The big news for .NET developers this week is the release of beta 2 of Visual Studio 2010 and the .NET Framework 4, which became generally available today (see VS2010 and .NET 4 Beta 2 Go Live). For developers of data-driven applications, beta 2 included some major improvements to the ADO.NET Entity Framework, Microsoft's new interface for providing access to apps using object-relational modeling (ORM) rather than programming directly against relational schema.

First released with the Visual Studio 2008 and the .NET Framework 3.5 SP1, the Entity Framework has become a polarizing issue among database developers. As covered extensively, the Entity Framework has been a godsend to many programmers who welcome the move to model-driven development.

However it has also been much maligned by those who prefer the tried-and-true ADO.NET data access mechanism or those who feel that there are better object-relational mapping technologies than Microsoft has to offer such as the NHibernate or Spring.NET.

Nonetheless Microsoft's Entity Framework stands out in another unique way: it is part of Visual Studio and the .NET Framework. And like it or not, it's here to stay.

"The Entity Data Model represents such a key strategic direction for Microsoft that spans all of our products," said Elisa Flasko, program manager in Microsoft's data modeling group in an interview. It initially spanned SQL Server, Visual Studio and the .NET Framework, while this week support for SharePoint Server was announced (see Microsoft Gives SharePoint A Facelift).

Flasko said the older data access languages and frameworks remain important. "We want to enable our customers and partners to increase their productivity, and better enable the integration across their applications, across Microsoft applications, and across the many different data sources," she said. "That said ADO.NET is a core part of the .NET Framework, as well, the Entity Framework, which builds on top of the traditional ADO.NET SQL client and provider model APIs in general."

With this week's release of beta 2, Microsoft has added a laundry list of features that appear to be welcome additions. Among them is support for Foreign Key Associations, improvements to POCO support, support for Lazy Loading by default in new models, support for binary keys, improvements to the Object Services API designed to allow n-Tier and self tracking entities, new extensibility APIs and improvements in LINQ to Entities. Flasko provides a much more extensive rundown in her blog posting.

Still to come though is the Feature CTP 2 version, which Flasko said should be released shortly.

Beta 2 also addresses a major complaint of the Entity Framework: it's weak of support for complex stored procedures, which is said to be remedied in this new release. For example, the user interface can now detect columns returned from a stored procedure and create a corresponding complex type, Flasko wrote in a blog posting. "In addition, existing complex types can be updated when a stored procedure definition changes," she noted.

"There is some heavy hitting stuff in this list," said Julie Lerman, an independent .NET consultant, who is writing an update to her book Programming Entity Framework (O'Reilly and Partners) covering the EF 4.  "For example having access to foreign keys and having foreign keys in the model is going to be a game-changer for a lot of people. They think it's so important that they've made it the default, that's a really, really big thing in this new version that we didn't have in beta 1."

The new lazy loading update will be welcome by some, criticized by others, Lerman tells me. "People who are used to using ORMs absolutely expect lazy loading to be there, while for people who are not used to using ORMs, this might be unexpected behavior for them. They can turn it off for sure, easily, but it's one of those issues that has been widely debated. Everyone using LINQ to SQL is used to lazy loading working, so it's not an insignificant change."

Overall, Lerman said, beta 2 is a significant update and she will have more to say once she spends some time testing it. 'These changes are going to have a huge impact on things that we've been looking forward to from moving from Entity Framework 1 to the new version," she said.

But Entity Framework has its critics. I was chatting with Andrew Brust, chief of new technology at the consulting firm twentysix New York, and he is not completely sold on the Entity Framework. "People don’t like the objects that the Entity Framework generates, they're not quite everything they would do if they wrote their own, so they are putting objects around the objects, and now you've got an extra layer of indirection," said Brust, who also writes a column for Visual Studio Magazine. (For his take on the Entity Framework, see The Value of Known Entities)

"Because instead of just writing your own objects around the ADO.NET code that would talk to the database directly, you are writing your objects around an Entity Framework object which then uses ADO.NET to talk to the database," Brust added. "That's the problem."

Flasko said she begs to differ noting the support for T4 templates and improvements to POCO. "You are writing objects that then become the Entity Framework objects, so the T4 [templates] will actually generate the Entity Framework objects but it will generate them customized to your specifications," she said. "It will generate them, shape the way that you actually want them shaped for your business practices or for your applications and then with the POCO objects you are creating very, very simple plain CLR objects that become the Entity Framework objects in that instance as well."

Those partial to other ORM technologies were even more critical in their assessment of the Entity Framework. "Even with EF4, it still hasn't begun to get close to the feature set that NHibernate had 4-plus years ago, not to mention the features in NHibernate 2.1 and Fluent NHibernate," said .NET consultant Chad Myers, in an email. Myers was part of the original team that invented Fluent NHibernate.

"As far as I'm concerned, EF is a marked step backwards in progress in the .NET space and represents the 'wrong' side of the internal struggle within Microsoft to be more open, engaged, and cooperative with the flourishing .NET open source ecosystem that has erupted in spite of Microsoft's efforts," he said.

I will be writing more on this and would like to hear your views. Please drop me a line at [email protected] or comment below.

Posted by Jeffrey Schwartz on 10/21/2009


comments powered by Disqus

Featured

Subscribe on YouTube