Entity Framework query ToString won't produce SQL query

c# entity-framework entity-framework-5 entity-framework-6

Accepted Answer

You can do the following if you don't need the SQL BEFORE it is run on the database:

dbContext.Database.Log = s => Debug.WriteLine(s);

This would output some more info as well as the SQL to the debug output.
For further information, click here: http://msdn.microsoft.com/de-DE/data/dn469464

Before attempting to obtain the SQL through, as martin costello said, double check that you are not querying the database.ToString() . It also happened to me that I had already acquired objects as a result of usingIEnumerable<> "to soon" (in place ofIQueryable<> ) and as a result, pulled significantly too many things from the database and performed some filtering "in code" rather than "in SQL"

3
4/22/2014 3:14:45 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow