You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhancement : allow to inject custom data merging service instead of throwing InvalidOperationException when adding and object already tracked with the same key
#8155
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) !
The text was updated successfully, but these errors were encountered:
@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
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) !
The text was updated successfully, but these errors were encountered: