How to see the actual SQL query generated by Entity Framework

It is really simple:

  1: using (TailspinToysEntities context = new TailspinToysEntities())
  2: {
  3:   context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);
  4:  
  5:   var products =
  6:       from product in context.Products
  7:       where product.BasePrice > 5.00m
  8:       select product;
  9: }

 

This will show the SQL in the Output -> Debug window.