I have a bit of an issue with this task. Namely getting concurrency exceptions.
I've been searching through the code a bit to see if I could help with the task, and from what I could find the blocking occurrences are the following services:
SqlStringLocalizerFactory
DevelopmentSetup
Due to the caching it makes sense to keep them as Singleton. I'd go with changing the DbContext scope to Scoped or Transient and consume it as it in intended in background service (consume IServiceProvider and create a scope, docs).
If (almost) all lock (_context) in the SqlLocalizerFactory are replaced with creating a scope, the issue should be resolved.
Please correct me if I'm wrong and if I missed any case since I'm not using the library to the full extent. If this is it, I could make the necessary changes.
Hello!
I have a bit of an issue with this task. Namely getting concurrency exceptions.
I've been searching through the code a bit to see if I could help with the task, and from what I could find the blocking occurrences are the following services:
Due to the caching it makes sense to keep them as Singleton. I'd go with changing the DbContext scope to Scoped or Transient and consume it as it in intended in background service (consume IServiceProvider and create a scope, docs).
If (almost) all
lock (_context)
in the SqlLocalizerFactory are replaced with creating a scope, the issue should be resolved.Please correct me if I'm wrong and if I missed any case since I'm not using the library to the full extent. If this is it, I could make the necessary changes.