EF Repository Update

Posted 封存的记忆

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了EF Repository Update相关的知识,希望对你有一定的参考价值。

问题描述:


解决办法:


http://www.cnblogs.com/scy251147/p/3688844.html

原理:



Attaching an entity of type \'\' 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.

以上是关于EF Repository Update的主要内容,如果未能解决你的问题,请参考以下文章

EF Generic Repository 从新插入的通用实体获取 Id

您如何处理仅使用 EF4 plus Repository Pattern 显示视图的应用程序?

ABP CORE+EF 批量删除修改

UnitOfWork + Repository 模式和实体框架模拟

带有延迟加载的EF4 POCO。为什么fixup迭代整个数据库?

EF批量插入数据缓慢解决方法