How to View generated SQL from your LINQ Query while development?

⏩ You can simply do that by adding a new log level to show database commands in Output window of visual studio

⏩ So every time you run the LINQ query, the generated SQL statement will be printed in output window
 
⏩ Make that log level change in appsettings.Development.json so it's only logged in dev mode because we usually don't want to log every query in a production app
 
There are other ways to check the generate SQL from LINQ like SQL profiler, but it seems quite simpler to setup.

Post a Comment

0 Comments