Is there anyway to see what SQL query EF Core is generating? (ASP .Net Core 1.1)
Asked
Active
Viewed 7,317 times
8

Fabricio Rodriguez
- 3,769
- 11
- 48
- 101
-
Breakpoints with debugger or logging? – J. Doe Jul 12 '17 at 12:30
-
Thanks for the quick reply, and sorry, I should've been more specific... Breakpoint with debugger if possible? – Fabricio Rodriguez Jul 12 '17 at 12:33
-
Sure. You might also use logger (https://github.com/aspnet/EntityFramework/issues/5106) – J. Doe Jul 12 '17 at 12:40
-
Refer this answer: https://stackoverflow.com/a/44296793/193634 – Rosdi Kasim Oct 07 '18 at 05:08
1 Answers
4
Just my opinion, but I believe the easiest, fastest and cleanest solution is to use SQL Profiler.
Just run the SQL Profiler that comes with SSMS, start the trace, execute the action that executes the query, pause the trace and check the exact query that was executed.
It's independent of the EF version you are using.

João Pereira
- 1,647
- 15
- 18
-
19
-
Correct, it doesn't. But it's the definitely the most common database engine used with EF.Not to mention that, for example, the official **MySql connector was made [available as a pre-release](https://learn.microsoft.com/en-us/ef/core/providers/mysql/) only 3 months after the initial release of v1 of NETCore**. NET Core and EF Core 2.0 were released more than 2 months ago and it seems that no [official support](https://downloads.mysql.com/docs/connector-net-relnotes-en.a4.pdf) is yet available. Of course there are other database engines, but EF Core is not the ORM of choice for them. – João Pereira Oct 27 '17 at 09:36
-
2@user743414 Right, but there are several workarounds to get similar information that Profiler displays. I never said that Profiler was the only way, but in my humble opinion, it's the best option available to data driven applications. You can check [this post](https://cmatskas.com/query-profiling-on-azure-sql/) from Christos Matskas that gives you two possible solutions to continue profiling the Azure SQL engine. – João Pereira Jan 22 '18 at 15:54