❔ EF blowing up trying to insert a relationship that already exists
Code and question are in the text file
15 Replies
don't do this
this is not how EF works
this is you telling EF to create a new
Thing
record, not to update an existing Thing
recordIn that
thingCopy
is a new Thing
record? I know that much... I probably should have specified that I'm doing that to bind thingCopy
to some Blazor components, and I want to be able to Cancel out without modifying the original thing
object.
Is it possible to revert changes on an unsaved EF entity?Cancel out without modifying the original thing objectin what regard? if you don't want to modify the original
Thing
object, then don't
never expose it to the UIYeah, I'm not -- that's what the copy is for.
the copy is for the UI?
Yeah
then why are you trying to save it?
I want to save the changes made to the copy -- as a potentially discardable stand-in for the original
thing
-- back to the original thing
record.then save changes made to the copy
That's what I'm trying to do
Thank you. 😄
this highlights the fact that you shouldn't be using
Thing
as your data model for the UI
that's your data model for storageFair
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.