Go to my github

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.

posted @ 2016-09-02 10:33  峡谷少爷  阅读(623)  评论(0编辑  收藏  举报