Best way to show the SQL trace of a LINQ query to Entity Framework 3.5?
I am using ASP.net and EF 3.5.
Dim dbo As Web.Portal.RBMEntities = New Web.Portal.RBMEntities
Dim Query = From RoleAllocations In dbo.RoleAllocations Where RoleAllocations.user_id = _ID And RoleAllocations.expire_date > Today Select RoleAllocations
' Console write the SQL trace???
Thankyou!
I just attempted to do this:
Dim TraceString As String = TryCast(Query, ObjectQuery).ToTraceString
Which works great and returns the SQL trace of the LINQ statement.
Use SQL profiler?... assuming you mean SQL Server
Entity Framework Profiler found here http://efprof.com/ does this very elegant.
It is easy to start using, and it also gives some hints on possible "issues" with your queries. It will help you get an understanding about whats going on under the "EF hood".
It is not free but there is a 30 days trial for it. I would recommend it for EF newbies as it can be confusing to understand the way EF abstracts the database chatter.
The setup is smooth and its lightweight.
Once downloaded, read the "How to use.txt" to get it going.