Mid ASP.NET Core

Handling resource cleanup (e.g. DbContext disposal)?

  • Use DI to manage lifecycle of DbContext as Scoped.
  • Avoid manual disposal; rely on DI container.
  • Dispose IDisposable objects promptly when created manually.
  • Use using statements for short-lived resources.

More from ASP.NET Core Tutorial

All questions for this course