-
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
Provide a hook for identity resolution #20124
Comments
Related: identity resolution for no-tracking queries #19877 |
I just ran into this problem and would like to promote this proposed solution. In my case I have to take a slower route in order to prevent hitting the same entity multiple times. It would be extremely nice for my case if I could somehow just say "don't worry about conflicts. I know they're ok". To give some context, I was using FindAsync() to take advantage of already tracked entities but was then using RemoveRange() on a foreign keyed entity which triggers adding the parent entity to tracking. Since I have no control over that it has become impossible for me to use FindAsync() and I now will have to take the slow route to the database for each of those calls. |
Part of #626 Fixes #20124 This is essentially a call back that happens when an instance withe the same key as an existing tracked instance is attached. The existing instance is always retained, but the interceptor gets the chance to change property values of the tracked instance. This will typically be used to copy over values from the duplicate instance (i.e. painting from a detached entity) or just skip the duplicate. Interceptor implementations are provided to do these two things.
Part of #626 Fixes #20124 This is essentially a call back that happens when an instance withe the same key as an existing tracked instance is attached. The existing instance is always retained, but the interceptor gets the chance to change property values of the tracked instance. This will typically be used to copy over values from the duplicate instance (i.e. painting from a detached entity) or just skip the duplicate. Interceptor implementations are provided to do these two things.
In general, identity resolution is a difficult problem. See #20116 (comment) and many other similar comments over the years.
However, maybe we could provide a hook that applications can do to implement their own identity resolution when EF starts tracking a graph. This likely wouldn't cover difficult were merging needs to happen, but simple cases where duplicates can be essentially ignored could become much easier.
The text was updated successfully, but these errors were encountered: