Entity Framework Gets Code First (but Not Enum Support!)
No need to wait for that next major .NET Framework upgrade to get Entity Framework improvements, as a stand-alone EF installer is about to be released for the first time.
Entity Framework CTPs have been out for months and have alleviated many user concerns, and Entity Framework 4.1 is due to arrive any week now to address more.
It includes two major components: a DbContext API and Code First capability. The former is basically a simplified and enhanced ObjectContext. Most of the buzz among developers is around the new Code First component.
"Code First alleviates any need for a visual model, you can just create your classes, add any needed configurations to make sure they align with EF rules and go," said EF expert and author Julie Lerman in an interview. "You get the benefits of the ORM [object relational mapping] features offered by EF without the extra layer of having to create your model in a designer and then futz with a code generator to get your classes the way you want them."
Alleviation of the futz factor is a definite plus, indicated Tim Laverty, who as the lead program manager on the Microsoft EF team probably knows as much about Entity Framework as anyone in the world. In an interview, Laverty said Code First "offers a way for 'code-oriented' customers to build EDM [Entity Data Models] models and use EF. Previously, tooling or a command-line interface was required to create your model unless you were willing to create and edit complex XML files."
Laverty also mentioned that EF 4.1 supplies several conventions, such as database creation, to help developers build apps easier, and also has rich ASP.NET MVC integration.
And developers are likely to be excited about the new DbContext API, too, said Lerman, who wrote a preview of EF 4.1 in MSDN Magazine [full disclosure: my day job is features editor for the mag]. "It's not just that the amount of exposed properties and methods has been reduced," she told this site, "but there are a lot of coding tasks that have been simplified … whereas you have to do a little more juggling with ObjectContext to achieve the same ends."
While many developers lauded the new release when it was announced last week, there's still a big list of improvements they want, such as support for stored procedures, type conversions, enums, bulk updates and more.
"Darn it! No SP support? Cached queries? Very disappointing," said a user named Darius in the comment section of the ADO.NET team blog announcing the "Go-Live Release Candidate." "Guess we'll have to wait a bit longer to use this. Please just make sure that when you do implement, you do it right. Needs SPs to map to POCO objects or maybe even dynamic objects. Same goes for an ad-hoc SQL query."
Laverty sounded like he's heard about the enum clamor before. "Enum support!" he exclaimed when asked about future improvements (it's actually No. 1 on the uservoice site list, with more than 1,200 requests). "This is our top ask and is in our product plan for vNext," Laverty said. "After that, there's a large backlog: TVF [Table-Valued Function] support, Spatial support, better integration with database projects … better SQL gen, batch CUD [create, update or delete], second-level cache support, sharding support, migrations/database evolution, better [stored procedures] support" and more.
Laverty noted that disassociating EF from the evolution of Visual Studio and .NET Framework releases will help the EF team get improvements out faster--hopefully once per year. "We don't have a locked date for the release after 4.1 but are working on it now," he said.
He said you can let Microsoft know what features you'd like to see in EF in three main ways. "Give us feedback on our uservoice site, our forums, and our blog, please. We actively use each to build and prioritize our product backlog."
What would you like to see done to Entity Framework? Comment here or drop me a note.
Posted by David Ramel on 03/09/2011 at 4:55 PM