看来OptimisticConcurrencyException没有引发。
catch (OptimisticConcurrencyException)
{
this.currentContext.Refresh(RefreshMode.ClientWins, currentContext.User);
this.currentContext.SaveChanges();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error saving changes");
this.currentContext.Refresh(RefreshMode.StoreWins, schoolContext.User);
}
最后的改变总是胜利,这是错误的。如果我有两个实例同时运行,则最后修改的用户将始终覆盖之前的更改。
正确的行为应该是保持较早的更改。
你们遇到过类似的问题吗?
为什么OptimisticConcurrencyException不触发?