I have 3 services: Bot, Time Monitor and Parser.
- Bot - receive and handle events from the user.
- Time Monitor - check the time every minute and notifies the user if the condition is met.It also runs the Parser at a certain time.
- Parser - parse and save data into database.
They all use DbContext
and are added as scoped services.
But when I add DbContext
as a scoped service, I may have an error when at the same time we receive an event from the user and check the time (and parse data).
Therefore, I add DbContext
as a transient service, but they write on the internet that this can cause errors.
I can also register Bot and Parser as Transient services, but I can't register Time Monitor except as a singleton service because I need to check the status every minute.
What solution exists?
P.S sources - https://github.com/yungd1plomat/Timetable/tree/master