views:

273

answers:

2

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?

+2  A: 

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

Jason Miesionczek
Ah.. got me by 3 seconds. =)
StingyJack
Ideally, I'd like to output to a file or view the SQL in Visual Studio and avoid having to run profiler or use an additional tool.
Matthew
LINQ to SQL and Entity Framework are not the same. Entity Framework context does not have this option.
Matthew
Nice, never knew that about L2S, just another reason I'm glad I went with it over EF :)
Allen
+2  A: 

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

Allen
LINQPad is great for selects, but I need this for all transactions (i.e. select, insert, update, delete) – Matthew 5 mins ago
Matthew
LINQPad does all of those as well, just checked myself
Allen
Thank you, I see that now. I was hoping for a different solution but this will work.
Matthew