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.
- By Michael Domingo
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.