Support multiple constructors with DbContext pooling
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
### What problem are you trying to solve?
DbContext pooling doesn't work if the DbContext has multiple constructors.
I think this is a bit too strict, as only one constructor is needed with exactly one parameter DbContextOptions.
An usecase for multiple constructors for example is with the tool Linqpad but you need to separate constructor to use it for Linqpad.
The error thrown is `The DbContext of type '{contextType}' cannot be pooled because it does not have a public constructor accepting a single parameter of type DbContextOptions or has more than one constructor.`
The check is present in DbContextPool.CreateActivator() and could be changed to only check if a constructor is available with 1 parameter of type `typeof(DbContextOptions) || p.ParameterType == typeof(DbContextOptions))`
### Describe the solution you'd like
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.