News

Microsoft Details LINQ Overhaul in New Entity Framework Core 3.0

Entity Framework Core 3.0, which shipped on Sept. 23, includes a new LINQ implementation that Microsoft explained in an announcement post.

LINQ (Language Integrated Query) uses C# code to query various types of data stores, providing IntelliSense, strong typing and other benefits in an alternative to SQL queries.

In moving LINQ functionality to Microsoft's new, cross-platform, open source flagship Object-Relational Mapping (ORM) tool, Entity Framework Core, the dev team faced some tricky obstacles in lining everything up correctly in a series of EF Core 3.0 previews, which required some workarounds.

In yesterday's announcement of EF Core 3.0, Diego Vega, program manager for .NET Data Access, detailed the LINQ overhaul.

"We rearchitected our LINQ provider to enable translating more query patterns into SQL, generating efficient queries in more cases, and preventing inefficient queries from going undetected," Vega said. "The new LINQ provider is the foundation over which we'll be able to offer new query capabilities and performance improvements in future releases, without breaking existing applications and data providers."

Major changes included limiting client-side evaluations of queries that included LINQ expressions that couldn't be converted to parameters or translated to SQL. Those client evaluations could bog things down in big databases so their scope was restricted.

Also new is a design change that sees a single SQL statement generated for each LINQ query. The previous scheme of generating multiple SQL statements in some situations could cause problems.

Other new features detailed by Vega include:

  • Cosmos DB support
  • C# 8.0 support
  • Interception of database operations: "The new interception API in EF Core 3.0 allows providing custom logic to be invoked automatically whenever low-level database operations occur as part of the normal operation of EF Core."
  • Reverse engineering of database views: "Query types, which represent data that can be read from the database but not updated, have been renamed to keyless entity types. As they are an excellent fit for mapping database views in most scenarios, EF Core now automatically creates keyless entity types when reverse engineering database views."
  • Dependent entities sharing a table with principal are now optional: "Starting with EF Core 3.0, if OrderDetails is owned by Order or explicitly mapped to the same table, it will be possible to add an Order without an OrderDetails and all of the OrderDetails properties, except the primary key will be mapped to nullable columns."

Vega also announced the debut of Entity Framework 6.3, a holdover from the proprietary, Windows-only .NET Framework that's being subsumed in favor of the Core direction.

"We understand that many existing applications use previous versions of EF, and that porting them to EF Core only to take advantage of .NET Core can require a significant effort," he said. "For that reason, we decided to port the newest version of EF 6 to run on .NET Core 3.0."

Now the dev team is focused on completing existing documentation and working on EF Core 3.1, coming up later this year. The .NET Core platform is scheduled for v3.1 update in November.

One question still up in the air, as posed by a couple comments to Vega's post, is Universal Windows Platform (UWP) support.

"UWP would need to support .NET Standard 2.1," Vega replied. "I have tried to find out when/if this is going to happen, but didn't get a definitive answer. I will try again."

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus

Featured

  • Full Stack Hands-On Development with .NET

    In the fast-paced realm of modern software development, proficiency across a full stack of technologies is not just beneficial, it's essential. Microsoft has an entire stack of open source development components in its .NET platform (formerly known as .NET Core) that can be used to build an end-to-end set of applications.

  • .NET-Centric Uno Platform Debuts 'Single Project' for 9 Targets

    "We've reduced the complexity of project files and eliminated the need for explicit NuGet package references, separate project libraries, or 'shared' projects."

  • Creating Reactive Applications in .NET

    In modern applications, data is being retrieved in asynchronous, real-time streams, as traditional pull requests where the clients asks for data from the server are becoming a thing of the past.

  • 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.

Subscribe on YouTube