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

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

    Try simple change state for entity wich you trying update and SaveChanges()

    public bool Update(TEntity entity)
    {
    
            context.Entry(entity).State = System.Data.EntityState.Modified;
            context.SaveChanges();
            return true;
    }
    

提交回复
热议问题