I ran into problems using a DbContext with Blazor components using InteractiveServer render mode, so now I have to change all injections of my DbContext into a IDbContextFactory. Fun times...
Comments
Log in with your Bluesky account to leave a comment
I've been encapsulating EF usage with a DbContextProvider interface for ages now, and it hasn't failed me yet. I find recommending the injection of DbContext everywhere as the default approach a terrible decision on the EF team's part, too many footguns.
It helped me by having the scope be from the Inception of the command and shared amongst all the handlers. It also meant I could get rid of repositories which I've never been a fan of
Problem with Blazor interactive server rendering is that the scope is really long lived (think potential hours), so you cannot rely on the DI framework.
Comments