StilauGamer
Explore posts from serversInject IDbContextFactory or DbContext directly?
Yeah, its just that you use the same db context over the whole user request..
In Blazor, 1 scoped service last from when he starts viewing till he closes / refreshes, etc..
So in theory, when using a db context, you have it alive for the whole time, if its not disposed at some point tho ofc..
But then I don't need to do it in my web apis :sunglas:
Another mystery solved for today! 🫡
15 replies
Inject IDbContextFactory or DbContext directly?
From my understanding, the DB Context Factory is more widely used within Blazor applications where the scope is more wide...
The scope is per user request and not just a HTTP request like in a Web API..
So its more recommended to manually create the db context, etc in Blazor.
But in a Web API, you are good enough with just injecting the DB Context directly as its scoped to that request only..
Thats from what I understood.
Reference to the article
15 replies
Discord.Net + MagicOnion, heheh
ahhh, went training so didn't see the last messsages.
Basically waht it does is that the source generator detects this
[LoggerMessage(.........)]
and then creates the code inside the method automatically.
Right?137 replies