News

Entity Framework 6.2 Emerges Out of Preview

This more fully-fledged version of Microsoft's object relational/mapper is now at the initial beta testing stage, with quicker startups and a number of fixes from the preview, but there's also more work to do to resolve some issues that can impact EF providers. Also: a list of new features of the EF Core 2.0 preview released at Build.

A version of the Entity Framework runtime has emerged out of preview, and it's now in the initial beta stage. Dubbed EF 6.2 Beta 1, it comes with a number of fixes for issues that surfaced in the preview, and it's now faster at startup. But there is some work to do, and the .NET team is looking for help to resolve some issues impacting EF providers.

"We suspect some of the existing EF providers could be negatively impacted by a fix included in our tooling in this release, and we are asking for help from provider writers to validate this hypothesis," wrote Diego Vega, a program manager with Microsoft's EF team, in a blog post.

"The fix addresses a long-standing problem with schema discovery queries used in the 'Update model from database' feature of the EF tools," he explained. "When using the feature against a database with a large number of objects, the schema discovery queries can contain large numbers of parameters." He noted that SQL Server is limited of 2,100 parameters per query, and failures can occur with models that contain more than 300 objects because of the complexity with how queries and parameters are generated. So, the workaround, he said was to reduce "the number of parameters required by schema discovery queries by reusing parameter objects for each distinct value." A more detailed explanation of the fix is in this pull request on GitHub.

Vega noted that the fix was implemented in shared code and applied to all providers, but because of the way some providers "implement schema discovery by matching patterns in the schema discovery queries and then translating those patterns into calls to their native schema discovery API calls," the fix might actually break with some of those providers.

It's worth noting that Entity Framework continues to be enhanced and improved, even though the runtime is being superseded in future versions of Visual Studio with Entity Framework Core. EF Core is currently at version 1.0, with a version 2.0 preview made available at Build earlier this month. As such, EF 6.2 Beta 1 consists mainly of improvements and fixes, of which these ones were highlighted in Vega's blog:

  • Reduce start up time by loading finished code first models from a persistent cache
  • Fluent API to define indexes
  • EF tools Update Model issue when provider reports nullable keys
  • Add DbFunctions.Like() to enable writing LINQ queries that translate to LIKE in SQL
  • Migrate.exe should support -script option
  • Updating large models from database can make sp_executesql fail with too many parameters

The blog post also provides guidance on downgrading back to the originally installed EF tooling install, should developers run into issues using this initial beta.

The beta release of EF 6.2 runtime follows a preview release of EF Core 2.0 that was let loose at Build a few weeks ago. Microsoft describes EF Core as a "lightweight, extensible, and cross-platform version" of EF. Among the improvements to this version:

  • Enhanced LINQ translations and query execution
  • Addition of EF.Functions property that EF Core or providers can use "to define methods that map to database functions or operators so that those can be invoked in LINQ queries"
  • Types can be mapped even though they might not "posses their own identity and for which instances can only be tracked and referenced as dependents of instances of other entity types"
  • Global query filters
  • DbContext pooling
  • Manual compiled queries are more performant

Details of each of these features are contained in this blog post.

About the Author

Michael Domingo is a long-time software publishing veteran, having started up and managed several developer publications for the Clipper compiler, Microsoft Access, and Visual Basic. He's also managed IT pubs for 1105 Media, including Microsoft Certified Professional Magazine and Virtualization Review before landing his current gig as Visual Studio Magazine Editor in Chief. Besides his publishing life, he's a professional photographer, whose work can be found by Googling domingophoto.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube