分类

链接

2024 年 9 月
 1
2345678
9101112131415
16171819202122
23242526272829
30  

近期文章

热门标签

新人福利,免费薅羊毛

现在位置:    首页 > .NET > 正文
The instance of entity type ‘Customer’ cannot be tracked because another instance with the same key value for {‘Id’} is already being tracked.
.NET 暂无评论 阅读(24)

我的办法是,在编辑时,重新从数据库中查询一次即可。
var c = dbContext.Customers.FirstOrDefault(f => f.Id == id);

//update c

dbContext.SaveChanges();

============ 欢迎各位老板打赏~ ===========

本文版权归Bruce's Blog所有,转载引用请完整注明以下信息:
本文作者:Bruce
本文地址:The instance of entity type ‘Customer’ cannot be tracked because another instance with the same key value for {‘Id’} is already being tracked. | Bruce's Blog

发表评论

留言无头像?