Add ServiceCollection extension method for removing a DbContext or its options #33571
Labels
area-dbcontext
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
type-enhancement
Milestone
When creating integration tests for a project with ASP.NET Core, you probably want to modify the already registered DbContext with your options for testing. So for example, you may want to change the connection string or enable sensitve data logging.
To do so you you cannot just call again AddDbContext with your new options, as they are registered with TryAdd. You have to mess with serviceDescriptors and remove the options for that DbContext (once you know that removing the descriptor for DbContext is not what you need).
Code sample:
An extension method like the previous one could help in this case for removing DbContexts or its options when needed.
The text was updated successfully, but these errors were encountered: