Solved

Profile Entity Framework queries?

Posted on 2010-09-20
5
840 Views
Last Modified: 2013-11-11
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
0
Comment
Question by:Nargzul
  • 2
  • 2
5 Comments
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
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
0
 
LVL 1

Author Comment

by:Nargzul
Comment Utility
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
0
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
Comment Utility
I am no expert on SQL Server Profiler but found this on the web.

Using SQL Server Profiler
http://msdn.microsoft.com/en-us/library/ms187929.aspx

look at this link on the page:
Viewing and Analyzing Traces with SQL Server Profiler
0
 
LVL 8

Expert Comment

by:cubaman_24
Comment Utility
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
0
 
LVL 1

Author Closing Comment

by:Nargzul
Comment Utility
I've a lot of other request, so it's not very adequate
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now