How to get the sql generated by the entity framework [duplicate]
How can I get the sql script generated by an entity framework query? i.e. If I write
entityDataDontext.table1.Where(r => r.primarykey == 1).First();
then how can I get the SQL which should be somewhat like this:
select * from table1 where primarykey = 1
Thanks in advance :)
When you're going against SQL Server as your backend database, SQL Server Profiler is always the best tool to see exactly what SQL statements are being sent to your database to be processed.
See Introducting SQL Server Profiler for background info.
I can strongly recommend MiniProfiler: http://miniprofiler.com/
Besides using the SQL Server Profiler, you can try Entity Framework Profiler, which does that and more.
It's paid, with a 30-day trial.
精彩评论