Profile EntityFramework
entity-framework, sql
Solution
You have a few options here.
- Examine the query by printing it at runtime using `((ObjectQuery)query).ToTraceString()` see https://stackoverflow.com/a/7901917/1070291 (I think this only works for queries so may not be the best in the above scenario)
- Use SQL Profiler which is built into management studio
- Use Entity Framework Profiler (a very good third party tool with a trial version, this is what I use to analyse queries)
Problem
I have the following sample code: ``` Context context = new Context(); Repository repository = new Repository(context); Post post = repository.First<Post>(x => x.Id == 1); Model model = new Model { Created = cube.Created, Id = cube.Id, Name = cube.Name, Pack = cube.Pack.Id, Mimes = context.Files.Where(x => x.Id == 1).Select(x => x.Mime).ToList() }; ``` I need to find which SQL queries are being sent to the database. How can I profile the EF queries using SQL Express and VS 2012? Is there any tool for this?