Whenever I make a query with Entity in debug mode, it's possible to see the SQL script that creates, there's any way to get them without actually debug each request at the time?
Asked
Active
Viewed 104 times
1
-
3You can [redirect the log](https://stackoverflow.com/questions/16880687/how-can-i-log-the-generated-sql-from-dbcontext-savechanges-in-my-program) output. – Jasen Jul 27 '17 at 18:52
-
I find the best way to work with EF queries is to capture them in a profiler. For SQL Server I use Express Profiler. In cases where you need to connect to a shared database with lots of traffic I create a unique user for my context under test to use, then capture my snapshot, export to Excel and filter by User. From there you have SQL statements you can look for lazy loads, copy across to SSMS check execution plans, etc. – Steve Py Jul 27 '17 at 22:02