Profile EntityFramework

后端 未结 2 1729
你的背包
你的背包 2021-02-10 09:55

I have the following sample code:

  Context context = new Context();
  Repository repository = new Repository(context);

  Post post = repository.First

        
2条回答
  •  被撕碎了的回忆
    2021-02-10 10:03

    You have a few options here.

    1. 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)
    2. Use SQL Profiler which is built into management studio
    3. Use Entity Framework Profiler (a very good third party tool with a trial version, this is what I use to analyse queries)

提交回复
热议问题