-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data access within ChangeTracker.Tracked event throws InvalidOperationException #12615
Comments
@divega As discussed on Skype, this is the issue we hit when using the Tracked event as a workaround for the lack of an ObjectMaterialized/OnLoaded type event (further discussion regarding this in #626). We're currently working around this via custom |
@ajcvickers Let's discuss next time we have a chance. |
@ajcvickers you mentioned you had some thoughts about this. Any chance you can summarize? |
Talked about it with @divega and it looks like we need to investigate:
|
Opened #14534 for the query critical section part. Leaving this issue to track the Tracked event work. |
Performing a data access operation within the
ChangeTracker.Tracked
event results in anInvalidOperationException
being thrown due to the EF Core code being within a critical section.We were really hoping to use this event to get around the lack of lifecycle hooks (#626).
In our specific case, we are porting a codebase from LINQ to SQL to EF Core. This codebase extensively used the LINQ to SQL OnLoaded() partial implementations.
Is there any chance that the Tracked event could be modified to allow data access to occur within the event delegate?
Steps to reproduce
Repro included at https://github.com/optiks/EFCore-TrackedEventCriticalSection.
At a high level:
ChangeTracker.Tracked
eventFurther technical details
EF Core version: 2.1
Database Provider: EntityFrameworkCore.SqlServerCompact35
Operating system: Windows 10.0.17134.112
IDE: Visual Studio 2017 15.7.2
The text was updated successfully, but these errors were encountered: