Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Profile Entity Framework queries?

Posted on 2010-09-20
5
Medium Priority
?
851 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 64

Expert Comment

by:Fernando Soto
ID: 33716488
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
ID: 33716560
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 64

Accepted Solution

by:
Fernando Soto earned 1500 total points
ID: 33716994
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
ID: 33723493
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
ID: 33838979
I've a lot of other request, so it's not very adequate
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

916 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