ServiceStack includes the awesome MiniProfiler built in. However, it is a different version, compiled into ServiceStack, in it’s own namespace.
I have got the profiler working with normal ADO.NET connections, but I am struggling to make it work with my Entity Framework 4.2 data contexts.
Normally, one would use the MiniProfiler.EF NuGet package, but since it is built against the official MiniProfiler version it does not work.
What is the easiest way of either:
- Swapping out the MiniProfiler in ServiceStack for the official version (I researched this and it does not seem easy, since SS generates the JavaScript for the profiler deep in some handlers) ?
- Or, making the built in profiler work with ServiceStack AND Entity Framework ?
So, I didn’t get any good answers on this, so I decided the way to go was to port MiniProfiler.EF to run against ServiceStack. Luckily, this was not too much of an effort.
The result is here: https://github.com/driis/ServiceStack.MiniProfiler.EntityFramework
It is the exact same code as what is in MiniProfiler.EF, just adjusted namespaces and fixed a few errors to make it compile. To use, simply put the assembly in your project (instead of the MiniProfiler.EF package), and call
MiniProfilerEF.Initialize_EF42()in your startup code – all done.I will probably try to make a pull request against ServiceStack.Contrib when I have the time, so it can be included there, possibly with it’s own NuGet package.