EF Core 5.0 Preview 6 Released

Microsoft announced the sixth preview release of EF Core 5.0. which includes split queries for related collections, a new “index” attribute, IP address mapping, improved exceptions related to query translations, exposing transaction id for correlation, and more. The preview also includes a number of bug fixes.
 
 
Source: Microsoft
 
EF Core 5.0 preivew 6 features split queries for related collections which is available for all relational database providers and can be used anywhere in the query, just like AsNoTracking. The company showed how the new feature can be used in code as below:
  1. var artists = context.Artists  
  2. .AsSplitQuery()  
  3. .Include(e => e.Albums).ThenInclude(e => e.Tags)  
  4. .ToList();  
The above code will generate the following three SQL queries:
  1. SELECT "a"."Id""a"."Name"  
  2. FROM "Artists" AS "a"  
  3. ORDER BY "a"."Id"  
  4.   
  5. SELECT "a0"."Id""a0"."ArtistId""a0"."Title""a"."Id"  
  6. FROM "Artists" AS "a"  
  7. INNER JOIN "Album" AS "a0" ON "a"."Id" = "a0"."ArtistId"  
  8. ORDER BY "a"."Id""a0"."Id"  
  9.   
  10. SELECT "t"."Id""t"."AlbumId""t"."Name""a"."Id""a0"."Id"  
  11. FROM "Artists" AS "a"  
  12. INNER JOIN "Album" AS "a0" ON "a"."Id" = "a0"."ArtistId"  
  13. INNER JOIN "Tag" AS "t" ON "a0"."Id" = "t"."AlbumId"  
  14. ORDER BY "a"."Id""a0"."Id"  
All operations on the query root are supported including OrderBy/Skip/Take, Join operations, FirstOrDefault and similar single result selecting operations. Also AsSplitQuery can also be used when collections are loaded in projections.
 
Preview 6 features a new IndexAttribute which can be placed on an entity type to specify an index for a single column. It can also be used to specify an index spanning multiple columns.
Microsoft said that preview 6 continues to improve the exception messages generated when query translation fails and better exception messages are now generated when attempting to translate string comparisons with culture-dependent semantics.
 
Starting with preview 6 EF Core now exposes a transaction ID for correlation of transactions across calls, which is typically set when a transaction is started. In cases when the application starts the transaction this feature allows the application to explicitly set the transaction ID so it is correlated correctly everywhere it is used.
 
With the latest release, the standard .NET IPAddress class now automatically maps to a string column for databases that do not already have native support. The scaffolding commands can now be instructed to ommit generation of OnConfiguring. And FirstOrDefault and similar operators for characters in strings can now be translated to SQL.
 
The release also features simplified case blocks.
 
For additional details, you can visit the official announcement here.


Next Recommended Reading EF Core 2.0 Preview 1 Announced