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 for Converge360.

comments powered by Disqus


Subscribe on YouTube