Attaching an entity of type 'X' failed because another entity of the same type already has the same primary key value

后端 未结 5 808
没有蜡笔的小新
没有蜡笔的小新 2021-01-04 09:25

ErrorMessage :

Attaching an entity of type \'FaridCRMData.Models.Customer\' failed because another entity of the same type already has the same prim

5条回答
  •  借酒劲吻你
    2021-01-04 09:58

    I believe you might have invoked Select before the update, By default, DBContext will cache the record when they are fethced (Selected), use "AsNoTracking()" in your select call while fetching record.

提交回复
热议问题