Skip to content

Instantly share code, notes, and snippets.

@pinalbhatt
Created March 9, 2015 14:14
Show Gist options
  • Save pinalbhatt/90da1ff10c401067d789 to your computer and use it in GitHub Desktop.
Save pinalbhatt/90da1ff10c401067d789 to your computer and use it in GitHub Desktop.
How to see the actual SQL query generated by Entity Framework in Visual Studio Debug Windows
using (TailspinToysEntities context = new TailspinToysEntities())
{
context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);
var products =
from product in context.Products
where product.BasePrice > 5.00m
select product;
}
//This will show the SQL in the Output -> Debug window.
//Source: http://blogs.msdn.com/b/mpeder/archive/2014/06/16/how-to-see-the-actual-sql-query-generated-by-entity-framework.aspx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment