When I call Refresh with RefreshMode.StoreWins in an entity that is in my context, and the values ββin the database are different from what is currently in the object, my object must update the current values ββwith respect to the database data, even if my entityState has not changed?
When editing an object, we create a new context and create a new class, ourClass (classId), which loads the current entity of our class type from the database. Making changes to our class and calling SaveChanges correctly stores the values ββin the database. After returning to the calling view model, we call Refresh in the existing context using RefreshMode.StoreWins, but this does not update the entity values ββin this context, even though the values ββin the database were correctly updated using SSMS. Any ideas what I should learn to solve this problem?
EDIT: A simple example of how we do things:
var context1 = new Model1(); LoadContext(); //loads all the data from the database and adds them to the context var context2 = new Model1(); var SelectedObject = context1.Table1.First(); OurObject selectedObjectForEdit = new OurObject(SelectedObject.ObjectId); context2.Table1.Add(selectedObjectForEdit); selectedObjectForEdit.Name = "new name"; context2.SaveChanges(); context1.Refresh(RefreshMode.StoreWins, SelectedObject);
source share