What is the idea behind a DbContext
class (EF)? Should I have one per model, one per application or maybe something else?
I guess I don't understand what they're used for. I get that I can put my data fetching logic in there, and that's great, but in that case, it seems to me that I should have one per model. Although if I have one per model, VS will create one connection string for each DbContext
, ie. for each model. I'm surely missing something here.
It's the "connection to the database" so to speak, and you would generally have one for each database you connect to. In general this is one per application. See, having a list of models is great, but you have to yet still have a connection to the actual database to get the data into those models.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With