I have a webshop running in a Blazor Web App application (server side). Everything works perfectly locally. But as soon as the application is online, it crashes every few days. This means that when I call up the application, the page loads indefinitely and I can't see any page. I then have to stop the whole application and restart it. Sometimes it works for a few days, but sometimes only for a few hours. I have noticed from the logs that this problem often occurs when the page is crawled.
I've been trying to get to the bottom of the problem for a while now. One possibility for the problem is EF Core. I have two scoped services that initialize an instance of EF Core DbContext and then discard it in the Dispose() function. Those services only track one entity with a few subentites, and changes to those entities can only be made through the corresponding service.
I know that a DbContext should only be kept as short as possible (as stated here), but I would also like to use the ChangeTracking of EF Core (UnitOfWork concept). Is there a way to do this? And can this problem really be the cause of the crashes? If not, what else could be the cause?
I found user with similar problems, but none of the solutions fixed my problem.