PawelGerr / Thinktecture.EntityFrameworkCore

These libraries extend Entity Framework Core by a few features to make it easier to work with EF and for easier integration testing or to get more performance in some special cases.
https://dev.azure.com/pawelgerr/Thinktecture.EntityFrameworkCore
BSD 3-Clause "New" or "Revised" License
66 stars 17 forks source link

ef core 6 (split queries) for included collection navigation get an error #14

Closed kliukvinda closed 2 years ago

kliukvinda commented 2 years ago

Thinktecture.EntityFrameworkCore 4.0.0-beta01

dbContext configuration: image

image

_context.BulkInsertIntoTempTableAsync: image

call example: image

in the first query the correct table name: image

in the second query, the table name is incorrect and we get an error: image

Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name '#TempTable< int >'

Please see what the problem might be? Thanks.

PawelGerr commented 2 years ago

The query splitting behavior "SplitQueries" in projection (i.e. in Select) is a new EF Core 6 feature. EF creates the second query by cloning the query - and that's a problem. I'm loosing important information when the expressions are cloned.

On first glance, it doesn't look like I can fix it (easily) because there are no extensibility points when expressions are being cloned. At the moment I see no other way as disallowing of temp tables in queries with query splitting behavior "SplitQueries" to prevent invalid SQL statements.