Solved

Profile Entity Framework queries?

Posted on 2010-09-20
5
848 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 63

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 63

Accepted Solution

by:
Fernando Soto earned 500 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

How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

635 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