I'm using miniprofiler in MVC project on App_Start() method I invoke
MiniProfilerEF6.Initialize()
and I get the error :
the Entity Framework was already using a DbConfiguration
instance before an attempt was made to add an 'Loaded' event handler.
'Loaded' event handlers can only be added as part of application start
up before the Entity Framework is used. See http://go.microsoft.com/fwlink/?LinkId=260883 for more information.
try to add MiniProfilerEF6.Initialize() in application_start function of your Global.asax and make sure it is the first line there.
protected void Application_Start()
{
StackExchange.Profiling.EntityFramework6.MiniProfilerEF6.Initialize();
}
If you have any PreApplicationStartMethod
's any where in the project, then make sure you move your MiniProfilerEF6.Initialize()
from Global.asax
to that class Start method
In my case I use static StructuremapMvc class to setup Ioc, and have
so have
[assembly: PreApplicationStartMethod(typeof(StructuremapMvc), "Start")]
public static class StructuremapMvc {
public static void Start() {
MiniProfilerEF6.Initialize();
...
...
this fixed for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With