ASP.NET Core & Web API (50 Qs)•Part 3: Distributed Systems, Kestrel Internals & Scalability (25 - 35)
What is the difference between `AddDbContext` vs. `AddDbContextPool`?
senior LevelSystem Design
In Simple Words:
AddDbContext: Instantiates a newDbContextinstance per HTTP request and discards it after.AddDbContextPool: Maintains a pool of reusableDbContextinstances. After a request completes, EF Core resets the context state and returns it to the pool, eliminating allocation overhead for high-traffic APIs.