3

So I am pretty new to EntityFramework, actualy in the POC stage right now, and one of the questions I am trying to answer is how can I visualize the query generated by EF through the debugger or other process attachable tool?

The case I am trying to solve is while trying to debug a QA, or production issue, the developer needs to be able to attach to the process through the remote debugger, and needs to visualize the query created by EF to see if it's framed in the most effective manner.

The same can be said during development, where I need to be able to visualize the query made by EF.

Russ
  • 12,312
  • 20
  • 59
  • 78

1 Answers1

3

You can either:

  1. Use Sql Server Management Studio Query Analyzer to see the traffic that goes to the database (probably the least invasive)
  2. Attach VS to your process and use IntelliTrace is should show commands sent to the database
  3. Try using EF Tracing provider (http://code.msdn.microsoft.com/EFProviderWrappers)
  4. For queries you can do .ToTraceString() on ObjectQuery object and .ToString() on DbQuery object when debugging.

EDIT

EF6 contains a new feature that allows you log the traffic to the database

Pawel
  • 31,342
  • 4
  • 73
  • 104