首页 新闻 赞助 找找看

EF中的报错

-1
[已关闭问题] 关闭于 2015-11-26 17:43

错误信息:

“System.InvalidOperationException”类型的异常在 EntityFramework.dll 中发生,但未在用户代码中进行处理

其他信息: Attaching an entity of type 'SH.Models.UserInfomation' failed because another entity of the same type already has the same primary key value. This can happen when using the 'Attach' method or setting the state of an entity to 'Unchanged' or 'Modified' if any entities in the graph have conflicting key values. This may be because some entities are new and have not yet received database-generated key values. In this case use the 'Add' method or the 'Added' entity state to track the graph and then set the state of non-new entities to 'Unchanged' or 'Modified' as appropriate.

 

源码

加了红色框框的代码就报错鸟 就加了个判断 和查了下个ID 思路就是先断表中有没有UID这条数据 如果没有就添加 有就修改

啦啦啦啦德玛西亚的主页 啦啦啦啦德玛西亚 | 初学一级 | 园豆:71
提问于:2015-11-26 17:05
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册