【问题标题】:Is there a way to tell if an entity is attached while debugging / inspecting an entity in visual studio有没有办法在 Visual Studio 中调试/检查实体时判断是否附加了实体
【发布时间】:2014-12-10 03:15:31
【问题描述】:

在 Visual Studio 2013 中调试时,有什么方法可以判断实体框架实体是否附加到上下文

即,如果我快速查看一个实体,我怎么知道它是否已连接?

或者我需要编写一个扩展方法并快速观看吗?

【问题讨论】:

    标签: c# visual-studio-2013 entity-framework-6 visual-studio-debugging


    【解决方案1】:

    您可以通过其条目获取实体状态:

    context.Entry(entity).State
    

    其中context 是您的DbContext 实例,entity 是要检查的实体。

    【讨论】:

      猜你喜欢
      • 2012-04-19
      • 1970-01-01
      • 1970-01-01
      • 2011-09-07
      • 1970-01-01
      • 1970-01-01
      • 2011-11-22
      • 2013-09-04
      • 2014-01-03
      相关资源
      最近更新 更多