title: How do you show underlying SQL query in EF Core?
body: <p>At 3:15 from the end of this &quot;<a href="https://channel9.msdn.com/Blogs/dotnet/NET-Core-20-Released/" rel="noreferrer">.NET Core 2.0 Released!</a>&quot; video, Diego Vega shows a demo of new features in Entity Framework Core 2.0. As part of that, a dump of the underlying SQL is shown <em>in the console app</em>.</p>
  <p><a href="https://i.stack.imgur.com/TNaOI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TNaOI.png" alt="enter image description here" /></a></p>
  <p>I have seen many answers on Stack Overflow suggesting that people use an SQL profiler to view the underlying queries. But now I'm curious: how can you do what Diego Vega did, and get the query to show right there in the application?</p>
  <p>Update for .NET 6: EF logging is enabled by default in development. See <a href="https://github.com/dotnet/aspnetcore/issues/32977" rel="noreferrer">this GitHub issue</a></p>
  <p>Update: Diego added <code>&quot;Microsoft.EntityFrameworkCore.Database.Command&quot;: &quot;Information&quot;</code> to <em>appsettings.Development.json</em>. See <a href="https://stackoverflow.com/questions/45893732/how-do-you-show-underlying-sql-query-in-ef-core/66662556#66662556">How do you show underlying SQL query in EF Core?</a> for more details.</p>