Created
September 7, 2017 00:13
-
-
Save beeleebow/748d3f5f49010c32d876c99c4d33c6fd to your computer and use it in GitHub Desktop.
Log Entity Framework Queries to Debug Output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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