I'm working on my first Blazor project, and I'm facing a issue about object life time.
The exact problem is that my EF DbContext never get disposed, so after first database update, any subsequent update fail because of a exception telling me that the entity is already tracked by the context.
So after investigation, I've discover that all Dependency Injected service are resolved when the app get launched and never get disposed so are the DbContext which is injected as a UnitOfWork
In MVC, the end point object get disposed any time the call ends, so DbContext gets disposed, and this issue never occurs.
But in Blazor object life time are different. As a good practice should I manually get resolve the DbContext when needed, or did a miss something?
EDIT:
I should also add that my DbContext is added to IServiceCollection as Scoped