Skip to content
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

fix(#435): use TryAddSingleton when registering IStorageInitializer to avoid overwriting user configured initialisers #1490

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

esskar
Copy link

@esskar esskar commented Feb 22, 2024

Description:

It was not obvious how this feature works. adding a custom IStorageInitializer before calling UseCap is not working as the registration will get overwritten. This is not the case for the MySQL Initializer as this was already using the TryAddSingleton functionality

Issue(s) addressed:

Changes:

  • Calling TryAddSingleton when registering IStorageInitializer

Affected components:

  • InMemoryCapOptionsExtensions
  • MongoDBCapOptionsExtensions
  • PostgreSqlCapOptionsExtensions
  • SqlServerCapOptionsExtensions

Additional notes (optional):

I noticed that setting a custom IStorageInitializer

Checklist:

  • I have tested my changes locally
  • I have added necessary documentation (if applicable)
  • I have updated the relevant tests (if applicable)
  • My changes follow the project's code style guidelines

…tializer to avoid overwritting user configured initializers
@demorgi
Copy link
Contributor

demorgi commented Oct 29, 2024

as a temporary workaround you can override registration
After
options.UseMongoDB
do
services.RemoveAll<IStorageInitializer>(); services.AddSingleton<IStorageInitializer, CustomStorageInitializer>();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants