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

后端 未结 5 851
没有蜡笔的小新
没有蜡笔的小新 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 10:06

    If you are selecting some data in between Update operation (as i was getting problem). Don't use .ToList() or .Find() .... Instead of that use as IQueryable , then use .AsNoTracking()..... Problem solved.

提交回复
热议问题