Link to home
Start Free TrialLog in
Avatar of Nargzul
Nargzul

asked on

Profile Entity Framework queries?

Hi!
I want to see SQL request generated by LINQ. I've seen that some people use a "datacontext.Log = Console.Output", but I don't have a .Log on my datacontext.

So, how to do this? For me if there is an equivalent to Console.Output, it resolves my problem

(I'm using entity framework 4.0 and POCO object).

Thank you for the help
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Hi Nargzul;

In the Entity Framework there is no Log function in the ObjectContext as there is in Linq to SQL in the DataContext. You have two options that I know of, first is to use SQL Profiler on the server and look at the SQL command comming into the server, Second is to build a EFTracingProvider, the two links below is the EFTracingProvider lib code and the second link is a small sample showing how to implement one.

Tracing and Caching Provider Wrappers for Entity Framework
http://code.msdn.microsoft.com/EFProviderWrappers

Logging SQL statements in Entity Framework/Code First
http://jkowalski.com/2010/04/23/logging-sql-statements-in-entity-frameworkcode-first/

Fernando
Avatar of Nargzul
Nargzul

ASKER

It's only to debug a little thing, I don't want to make a big devlopment for this. How can I do this SQL Profiler? I've tried but I didn't found my requests
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello:
I've been using Entity Framework Profiler. I shows you the statements executed against your DDBB, even if it's Sql CE, and the only one I knows can do it. It also give you hints about how to optimize certain expensive queries and more features. You can try it for 30 days, download at:
http://efprof.com/
Best regards
Avatar of Nargzul

ASKER

I've a lot of other request, so it's not very adequate