-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MP.EF6 + ASP.NET identity + Owin #98
Comments
I am having this same issue after migrating to ASP.NET Identity. It seems the OWIN middleware does some EF configuring even before Application_Start is called? I've tried initializing in Application_Start, and in the ConfigAuth method of the OWIN startup class with no luck. |
In my case it was related to Ninject, specifically making an instance of DbContext within RegisterServices. When I've turned it off, MiniProfilerEF6 have started. Basically this error means that some other EF operations been made BEFORE calling MiniProfilerEF6.Initialize(). |
Is this still an issue in current code? These aren't platforms we're using so I'm unaware of specific issues here. |
Yes this is still an issue. I'm getting this problem on an OWIN application |
I've honestly never used this stuff, does anyone have recommendations here? If it's a breaking change, v4 (#144) would be the time to make it... |
@NickCraver I can't figure out how to add SQL Server or EF Core using v4, but once that's ready I can help troubleshoot the middleware/order-of-operations stuff here. |
@chadwackerman I don't have a EF Core version for v4 yet...I'll take a look this week and see what's actually needed there. We don't use EF at Stack, so I'm not super familiar with it, will have to dig in. I'll see how we pass a profiled connection in there. |
@chadwackerman The v4 alpha is up, with an EntityFrameworkCore package as well: https://www.nuget.org/packages/MiniProfiler.EntityFrameworkCore/ |
Just a note, I've never tried this with EntityFrameworkCore. This issue would happen for me with the .Net Framework 4.6 using EF6. |
@vishnu4 alpha8 is now up with latest support for both ASP.NET (and Core) and Entity Framework 6 (and Core), can you please tell me if these issues remain? |
Sorry, no luck. Same as before. I have the following in my packages.config:
I went to your code at https://github.com/MiniProfiler/dotnet/blob/master/samples/Samples.Mvc5/Global.asax.cs and updated my files to match yours. If i load up my application, i get:
which happens at the |
@vishnu4 Does |
that was it for me. I tried putting it as the last line in my PreApplicationStartMethod, and that still didn't work, but putting it as the first line did. All good after that, thank you. |
\o/ Woohoo I'm not crazy! Thanks for helping me figure that out @vishnu4 :) |
Closing this out, see above comments for the most likely cause of this behavior. |
When i tryed to init MP.EF6 in my Startup class, i have an exception 👍
Message : 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.
That exception was only occured when i migrate to ASP.NET Identity after that he is working fine
The text was updated successfully, but these errors were encountered: