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 at Converge 360.

comments powered by Disqus

Featured

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

  • VS Code Copilot Previews New GPT-4o AI Code Completion Model

    The 4o upgrade includes additional training on more than 275,000 high-quality public repositories in over 30 popular programming languages, said Microsoft-owned GitHub, which created the original "AI pair programmer" years ago.

  • Microsoft's Rust Embrace Continues with Azure SDK Beta

    "Rust's strong type system and ownership model help prevent common programming errors such as null pointer dereferencing and buffer overflows, leading to more secure and stable code."

  • Xcode IDE from Microsoft Archrival Apple Gets Copilot AI

    Just after expanding the reach of its Copilot AI coding assistant to the open-source Eclipse IDE, Microsoft showcased how it's going even further, providing details about a preview version for the Xcode IDE from archrival Apple.

Subscribe on YouTube

Upcoming Training Events