TemporalAsOf with NoTrackingWithIdentityResolution #27289
Labels
area-query
area-temporal-tables
customer-reported
punted-for-7.0
Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints.
type-enhancement
Milestone
Solution can be found lower down the page.
Problem
In
efcore
6.0.1, the TemporalAsOf extension is set to only create queries markedAsNotTracking
.Even the description of the method says it pretty clearly:
The problem appears when we want to do
TemporalAsOf
queries which have more complexity to them such as this:A mammoth query such as this can easily generate an error such as this:
First clue how to fix this is here
Second clue how to fix this is here
Third clue how to fix this is here
In short use a no-tracking query with identity resolution
Solution
I understand that using a
NoTrackingWithIdentityResolution
orTrackAll
when executing aTemporalAll
query can cause some clashes.I think we can quote @ajcvickers here to give a better explanation:
Originally posted by @ajcvickers in #26704 (comment)
Extrapolating from this, I can say that it should be pretty safe that we can use
NoTrackingWithIdentityResolution
on aTemporalAsOf
query. (Not sure what to say aboutTrackAll
though)In fact I have been using
NoTrackingWithIdentityResolution
on aTemporalAsOf
query for quite some time.I have created an extension method such as below:
A working example of this can be found in this repo here.
The changes that contain the code and usages can be found here
This can be used like this:
The
AsTracking(...)
method code can be found here. Issue would be of course with theTrackAll
option.I have been using this extension for quite some time now without any side effects.
The
TrackAll
option would have to be removed but this is still an easy fix.The text was updated successfully, but these errors were encountered: