Is AddDbContextPool supposed to release contexts from the pool?
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
### Question
I have a large context model, so I'm experimenting with context pooling.
My current setup is:
```
service.AddDbContextPool((provider, optionsBuilder) =>
{
AppDbContextOptionsFactory.Get(optionsBuilder);
});
```
When I run my app, everything seems to work ok, except the `active_dbcontexts` seems to indicate the pooled dbcontexts are created but never released. Is this the expected behaviour for this?

From debugging with EFCore symbols, it appears that `AddDbContextPool` uses a `ScopedDbContextFactory` that does not allow the lease to be released because `IsStandalone` is set to false.
### EF Core version
9.0.0
### Database provider
SqlServer
### Target framework
.Net 9
### Operating system
Windows 10
### IDE
vs 2022
Contributor guide
Assessment
This issue has not been assessed yet.