I am trying to implement a way to either shelve changes to an EF6 context while I dispose and reload it or to refresh the context without losing changes.
I have a lot of scenarios where the user is updating a foreign key relationship on an object and they need to refresh the combobox on the form with new data without resetting all of their work.
For example: The object starts as follows:
Foo.Name = "Joe"
Foo.Bar = SomeBar
The user wants to change the object to
Foo.Name = "Sam"
Foo.Bar = NewBar
But they can't because NewBar
needs to be created.
So, the user opens the Bar
creation form (which is using a different EF context) and makes NewBar
. When they return to the Foo
edit form, they expect to see NewBar
in the dropdown, but it is not there. They can close and reopen the form to see NewBar
, but now they need to change "Joe" to "Sam" again.
How can I get around this or implement a pattern that makes it a non-issue?