Solved

Profile Entity Framework queries?

Posted on 2010-09-20
5
846 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
asp.net, radiobuttonlist, c# 3 69
ASP.NET, Globalization, language indexes, translation, conversion. 2 71
Subtract dates in vb.net 6 35
What is needed to become a DBA? 7 56
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

751 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