Search code examples
c#visual-studio-2013entity-framework-6visual-studio-debugging

Is there a way to tell if an entity is attached while debugging / inspecting an entity in visual studio


Is there any way to tell if an Entity Framework entity is attached to a context when debugging in visual studio 2013

I.e if i quick-watch an entity how would i know if its attached?

or would i need to write an extension method and quick-watch that?


Solution

  • You can get the entity state by its entry:

    context.Entry(entity).State
    

    where context is your DbContext instance and entity is the entity to inspect.