-1

I would like to know how I could see the SQL command when I use the saveChanges method in Entity Framework.

I am using EF 4.4.

Thanks.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Álvaro García
  • 18,114
  • 30
  • 102
  • 193
  • 2
    What is the purpose of getting the query sting? Debugging/Tracing or do you need to use if for something else? Depending on the need, using SQL Server Profiler is the easiest. – Justin Jun 03 '13 at 14:55
  • @JustinNiessner I wouldn't consider it a duplicate because Alvaro is asking specifically about SaveChanges method which is different than when defining a query before excuting it. – Justin Jun 03 '13 at 14:56
  • Completely agree with @Justin, profiling the database is the best way to go here. Regardless of what the code is doing, regardless of how many levels of abstraction there are, regardless of any frameworks used... Ultimately something has to send a command to the database. Intercept that command from the perspective of the database, which doesn't care about the internals of the code. – David Jun 03 '13 at 14:58
  • This should also be on the list of exact duplicates: http://stackoverflow.com/questions/2483236/view-sql-generated-by-savechanges-in-ef – Justin Niessner Jun 03 '13 at 14:59
  • SQL Profiler captures the first 4000 characters of the query string. I hardly find myself looking at an EF query that is not cropped by that. –  Feb 27 '14 at 22:24

1 Answers1

1

I tend to use SQL Profiler what installs with management studio. It will show every request made to your SQL server.

Or as Justin pointed out you can do the follow: How do I view the SQL generated by the entity framework?

Community
  • 1
  • 1
pingoo
  • 2,074
  • 14
  • 17