News

Entity Framework Core 3.0 Finalized, LINQ Workarounds Published

As with other "Core 3.0" products, Entity Framework is basically done at this point as the big final release is less than two weeks away, and Microsoft has provided some workarounds for the problematic LINQ implementation in the new and final preview.

Microsoft said "We have almost completely stopped making changes to the product code" in announcing EF Core 3.0 Preview 9, but it's seeking feedback on any bugs that developers can find, even if they can't be fixed in time for .NET Core 3.0 shipping during the Sept. 23-25 online .NET Conf event.

Some of those bugs might have to do with LINQ, with which the EF dev team has struggled in the move to .NET Core 3.0.

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.

The problematic .NET Core 3.0 porting was explained last month in the release of Preview 8. "The LINQ implementation in EF Core 3.0 is designed to work very differently from the one used in previous versions of EF Core, and in some areas, it's still a work in progress," said program manager Diego Vega in an Aug. 13 announcement post. "For these reasons, you are likely to run into issues with LINQ queries, especially when upgrading existing applications."

With EF Core 3.0 basically finalized, Microsoft last week published some workaround advice:

  • Try a daily build to confirm that you aren't hitting an issue that has already been fixed.
  • Switch to client evaluation explicitly: If your query filters data based on an expression that cannot be translated to SQL, you may need to switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync() in the middle of the query.
  • Use raw SQL queries: If some expression in your LINQ query is not translated correctly (or at all) to SQL, but you know what translation you would want to have generated, you may be able to work around the issue by executing your own SQL statement using the FromSqlRaw() or FromSqlInterpolated() methods.

Along with EF Core 3.0 Preview 9, Microsoft also shipped Entity Framework 6.3 Preview 9, a holdover from the traditional, proprietary, aging and Windows-only.NET Framework that is now an independent offering. As the company explains the difference between the two:

  • Entity Framework 6 (EF6) is a tried and tested object-relational mapper (O/RM) for .NET with many years of feature development and stabilization.
  • Entity Framework (EF) Core is a lightweight, extensible, open source and cross-platform version of the popular Entity Framework data access technology.

Any bugs found can be reported to either the EF Core issue tracker or the EF 6 issue tracker on GitHub.

The EF dev team publishes weekly status updates on its progress on GitHub.

About the Author

David Ramel is an editor and writer at Converge 360.

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