How do I view the SQL generated by entity framework ?
(In my particular case I'm using the mysql provider - if it matters)
Duplicate: http://stackoverflow.com/questions/137712/sql-tracing-linq-to-entities#138109
How do I view the SQL generated by entity framework ?
(In my particular case I'm using the mysql provider - if it matters)
Duplicate: http://stackoverflow.com/questions/137712/sql-tracing-linq-to-entities#138109
There are two ways:
ToTraceString()
. You can add it into your watch window and set a breakpoint to see what the query would be at any given point for any LINQ query.tail -f
. You can learn more about MySQL's logging facilities in the official documentation. For SQL Server, the easiest way is to use the included SQL Server profiler.You can do the following:
var result = from x in appEntities
where x.id = 32
select x;
var sql = ((System.Data.Objects.ObjectQuery)result).ToTraceString();
That will give you the SQL that was generated.