How can I see the SQL created by Entity Framework?

entity-framework

Question

How can I read the SQL created by Entity Framework from inside my code, as the title suggests? I'm having trouble with an error where the EF crashes because a field (a DateTime field) is generated by the database. I thought I had set it up to know that the store is generating it via StoreGeneratedPattern, but it's still crashing, so I'd like to know exactly what it's trying to push up to the database.

P.S. I've only had EF for a little over an hour. I'm leaving L2S.

1
10
3/13/2012 7:25:12 PM

Accepted Answer

Since you don't have SQL Profiler, LINQPad is the best option for you. You may make use of your current assembly.

Click Add connection -> Use a typed data context from your own assembly -> Entity framework , then choose your dll.

You may directly write queries against your model (or copy-paste from your code). Choose theSQL To examine the resulting SQL code, 'tab' underneath the query window.

16
10/28/2010 6:54:55 AM

Popular Answer

The EF Profiler, Entity Framework may be used (EFProf). Although it costs money, a 30-day trial is offered. In addition to giving you the SQL statements, it performs a lot more interesting things.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow