Data Driver

Blog archive

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


comments powered by Disqus

Featured

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube