EntityFramework中的OptimisticConcurrencyException [英] OptimisticConcurrencyException in EntityFramework

查看:69
本文介绍了EntityFramework中的OptimisticConcurrencyException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

EntityFramework中的OptimisticConcurrencyException



我正在使用实体框架4.3.0,同时调用context.SaveChanges(),抛出异常消息...



System.Data.OptimisticConcurrencyException - >消息:存储更新,插入或删除语句影响了意外的行数(0)。自实体加载后,实体可能已被修改或删除。刷新ObjectStateManager条目。



i用Google搜索解决方案,我发现我必须刷新上下文,例如,



context.Refresh(RefreshMode refreshMode,Object entity)



但是,上下文没有任何Refresh方法..

* EF(v4.3.0)不包含此功能?

*所以应该采用另一种方法来修复它...



提前谢谢。

OptimisticConcurrencyException in EntityFramework

I am using entity framework 4.3.0, while calling context.SaveChanges(), exception thrown with message...

System.Data.OptimisticConcurrencyException--> Message: Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.

i googled for solution and i found that i have to refresh the context like,

context.Refresh(RefreshMode refreshMode, Object entity)

but, there is no any Refresh method for the context..
* EF(v4.3.0) does not include this functionality?
* so what should be another way to fix it..

thanks in advance.

推荐答案

这篇关于EntityFramework中的OptimisticConcurrencyException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆