0

I read in some places that it would be good to use a singleton context, but what if it was in a service? It will keep running all the time, making from time to time requests to a REST API, so I'm thinking, it will have an instance of the DbContext allocated on the memory.

What would be better, the using (var context = new DbContext()) or a singleton DbContext?

0

1 Answer 1

2

DbContext is cheap, and there is some housekeeping that occurs when they are created and disposed. Don't use a singleton for one.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.