问题
在调用Attach(user)时报告以下错误:
An entity object cannot be referenced by multiple instances of IEntityChangeTracker

原因
实体对象user的DbContext还没关闭,此时不允许再Attach到另一个DbContext上。
Attach的实体对象,必须是脱离DbContext的管制。

解决
先关闭做查询的DbContext,再Attach到做更新的DbContext中。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2021-09-11
  • 2021-08-14
  • 2021-10-02
  • 2021-12-30
  • 2021-06-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-01
相关资源
相似解决方案