Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework Generated SQL

Is it possible to output the SQL generated by the Entity Framework on a global level and not on a query by query basis? I'm looking to just dump it all somewhere so I can review it.

If that is not possible, how do I view the SQL being generated for updates and inserts?

like image 205
ctorx Avatar asked Aug 10 '09 19:08

ctorx


3 Answers

The SQL Server Profiler will allow you to view the commands that are being executed on the server while the application is running.

Another free tool for profiling SQL Server 2005 Express here.

UPDATE

Another method to see what is being generated by LINQ is the Log property of the DataContext.

It is a TextWriter that should be easy to save the contents to a file or redirect to Console.Out.

MSDN Info for Log property

like image 113
Jason Miesionczek Avatar answered Oct 14 '22 15:10

Jason Miesionczek


you want LinqPad, here are some videos that show you how to use it

like image 24
Allen Rice Avatar answered Oct 14 '22 15:10

Allen Rice


Since this was originally asked, you can also now use EFProf to profile your Entity Framework application, which allows you to see the SQL Generated among many other metrics.

like image 34
glenatron Avatar answered Oct 14 '22 17:10

glenatron