Skip to content
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

Enhancement : allow to inject custom data merging service instead of throwing InvalidOperationException when adding and object already tracked with the same key #8155

Closed
cdie opened this issue Apr 13, 2017 · 2 comments

Comments

@cdie
Copy link

cdie commented Apr 13, 2017

When trying to add an object within the context and EF is already tracking an object with the same key (it's not the same reference for whatever reason), it would be great if we can define our own merging service instead of disabling the change tracker and do all by hand.

The service should the entity EF already track and the one we try to add, and we should return one merged.

It could help us a lot (we rewrite a HUGE part of object updating/adding here) !

@ajcvickers
Copy link
Member

Note for triage: related to #5536

@ajcvickers
Copy link
Member

@cdie Having some way to better handle merging of disconnected entities is par of #5536. But anything we do there, and anything we do outside of that, would almost certainly involve resolving identity conflicts before the place we currently throw so that there would never be any attempt to track two instances of the same type. So the best thing to do now is to check before trying to track an instance that it needs to be merged with some other instance. Given that, there isn't really anything to do here other than what is already tracked by #5536

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants