Using mvc-mini-profiler

前端 未结 1 2121
囚心锁ツ
囚心锁ツ 2021-02-19 16:58

I\'m trying to use the mvc-mini-profiler with EFCodeFirst I\'m creating a DbProfiledConnection and passing it to the DbContext on construction as below. The application continu

相关标签:
1条回答
  • 2021-02-19 17:37

    I suspect this relates to the static field initializer. Connections on web apps should never be static anyway (but request-specific at most).

    The key is: what does ProfiledDbConnection actually come out as? The Get method returns a ProfiledDbConnection only if you are currently profiling (on the current request), and the connection is profiled against the MiniProfiler instance on that request.

    If you use a static field, then there are two scenarios:

    • the static field is initialized without a request context (or a non-developer request context): no profiling will occur as MiniProfiler.Current is null
    • the static field is initialized, but everything is logged against the very first request, which is quickly dead
    0 讨论(0)
提交回复
热议问题