Skip to content

Instantly share code, notes, and snippets.

@beeleebow
Created September 7, 2017 00:13
Show Gist options
  • Save beeleebow/748d3f5f49010c32d876c99c4d33c6fd to your computer and use it in GitHub Desktop.
Save beeleebow/748d3f5f49010c32d876c99c4d33c6fd to your computer and use it in GitHub Desktop.
Log Entity Framework Queries to Debug Output
/*
When you want to see the sql that entity framework is generating you
can turn on logging that will go to Visual Studios debug output
*/
using(var dbContext = new MyDbContext())
{
dbContext.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);
// do your queries here...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment