-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Design: Failure when UseMiddleware(args) is used #10502
Comments
Is there an argument it's expecting to be present? Maybe it's specified in |
I wonder if this has been mitigated in 2.1 by aspnet/Hosting#1263 |
@divega Note: update forward link in message. |
Updated fwlink 851728 to point to https://docs.microsoft.com/en-us/ef/core/miscellaneous/configuring-dbcontext which covers all supported patterns for configuring the DbContext at both run time and design time. I am planning to update the topic to call out more clearly the specific requirements of design time tools. |
How do you actually fix this problem? I have the exact same thing when trying to migrate. But when I run my app, it works perfectly fine. The "fix" is just a duplicate link to this thread, so it doesn't show an answer .. What am I missing here? |
@zugzwangm @hscanlan Do you have a repro project I can use to dig into this? |
I'm not able to repro this with the information provided. Here's what I tried: app.UseMiddleware<MyMiddleware>(new MyDependency()); class MyMiddleware
{
public MyMiddleware(RequestDelegate next, MyDependency dependency)
{
}
public Task Invoke(HttpContext httpContext)
=> Task.CompletedTask;
}
class MyDependency
{
} |
I'm stuck with this too. The only difference I can see, is that I use Perhaps if you change your attempt to the following (which is quite close to what I'm actually using) you can reproduce it (I did not try it this isolated though). services.AddSingleton(typeof(MyOtherDependency));
services.AddSingleton(typeof(MyDependency)); app.UseMiddleware<MyMiddleware>(serviceProvider.GetService<MyDependency>()); class MyMiddleware { /* (snip) (use your code) */ }
class MyDependency
{
public MyDependency(MyOtherDependency dep, IServiceScopeFactory ssf)
{ }
}
class MyOtherDependency { } |
Seems like a workaround is to comment out the offending |
Still not able to repro it. Let me know if you can isolate the issue. |
EF Team Triage: Closing this issue as the requested additional details have not been provided and we have been unable to reproduce it. BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions. |
dotnet ef migrations list
(and possibly other commands) fails when Startup.Configure() adds a Middleware withapp.UseMiddleware<MyMiddleware>(args)
. The app works flawlessly while running normally.Workaround is to avoid using
param object[] args
when calling UseMiddleware(), and inject everything through DI.Further technical details
EF Core version: 2.0
Operating system: Win10
IDE: Visual Studio 2017 15.4.5
The text was updated successfully, but these errors were encountered: