-
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
Make AddPooledDbContextFactory register DbContext in addition to the and factory #26528
Comments
AddPooledDbContextFactory
as wellDbContext
automatically when using AddPooledDbContextFactory
as well
DbContext
automatically when using AddPooledDbContextFactory
as wellDbContext
automatically when using AddPooledDbContextFactory
Same situation here. We use |
@ajcvickers Hi there, any reason as to why this was removed from 7.0.0? It seems like it would be relatively straightforward and simple to implement. |
@aradalvand We had to punt a number of smaller issues. While each in itself would not take a long time, that time quickly adds up. This one is also only sugar--it's easy to obtain the same functionality by registering trice--which makes it lower priority. |
@ajcvickers Hi, could this please be added to the v8 milestone? It doesn't take too much effort to implement but the API is just incomplete without it. Thanks. |
@xamir82 the project accepts pull requests 😉 |
Can you explain a bit more what you mean by this? To me, this is a bit of sugar that means people who need this don't have to add an extra line of code to register the service they want. |
DbContext
automatically when using AddPooledDbContextFactory
What would be the most correct workaround here?
(it does not seem wrong to me judging by basic tests, but maybe i'm missing something) |
AddDbContextFactory indeed already registers both IDbContextFactory and DbContext in DI (#25164), but AddPooledDbContextFactory indeed does not In the meantime, it should be fine to simply also call AddDbContext() after the call - without passing configuration to it (it should pick up the configuration already passed to AddPooledDbContextFactory): services
.AddPooledDbContextFactory<BlogContext>(o => o.UseSqlServer(...))
.AddDbContext<BlogContext>(); |
@roji why do you need a new issue? I know the title isn't clear but the first post seems quite clear they are asking for this in |
You're right, I looked at the title and didn't notice that the original post was specifically talking AddPooledDbContextFactory, and that AddDbContextFactory was working fine. I'll reverse the situation. |
In #25164 it was suggested that EF Core implicitly registers a scoped
DbContext
as well whenAddDbContextFactory
is used, which I thought was a great idea, and it was done in RC1 I think.But why not do the same thing for
AddPooledDbContextFactory
too?! I'm usingAddPooledDbContextFactory
in my project and I was surprised to see that the same thing isn't done in that method as well.The text was updated successfully, but these errors were encountered: