gpt4 book ai didi

c# - 调试时我能看到 ObjectStateManager 里有什么吗?

转载 作者:太空狗 更新时间:2023-10-29 23:09:10 25 4
gpt4 key购买 nike

背景

我在更新 EF 中的实体时遇到了一些问题。我不断收到此错误:

“ObjectStateManager 中已存在具有相同键的对象。ObjectStateManager 无法跟踪具有相同键的多个对象”

我完全意识到某处显然有另一个实体附属。但是,我目前无法追踪到它。有很多代码,我已经花了很多时间在上面。据我所知,我在所有查询中都使用了 AsNoTracking() 扩展方法。

我需要什么

我的问题是:有什么方法可以在任何给定时间查看 ObjectStateManager 中的实际内容?如果我可以在调试期间看到其中的项目,我可以更快地追踪它的来源。

如果以上不可能,我将不胜感激任何关于如何最好地解决这个问题的建议..它现在就像大海捞针。

最佳答案

Is there any way I can see what is actually in the ObjectStateManager at any given time? If I can see the items in there during debugging, I can more quickly track down where this is coming from.

您还可以使用 Visual Studio 调试器的快速查看功能查看 ObjectStateManager 中的内容。路径是:

context -> ObjectContext -> ObjectStateManager -> Non-Public members

关于c# - 调试时我能看到 ObjectStateManager 里有什么吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12869711/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com