Search code examples
c#sql-serverentity-framework-4

View EF4 generated queries?


LINQ-to-SQL had several ways, including a visualizer add-in, to view the generated SQL from an IQueryable.

I can't find the equivalent for Entity Framework 4. Nothing on StackOverflow, no blogs. How is it done?

Preferably, I'd like to be able to do it in code and without having to actually execute the query just to see it.

Thanks!


Solution

  • there are several approaches to looking at the sql.

    Free

    1. On the ObjectQuery do .ToTraceString() that will show u the sql generated for the query.
    2. Download ef tracing provider written by one of the EF team members. EF Tracing Provider
    3. Linq To Entities visualizer which you can download here.
    4. LinqPad
    5. Sqlserver profiler

    Commercial

    1. Efprof.com