---
title: "What is the difference between AddScoped, AddTransient and AddSingleton?"  
description: "What is the difference between AddScoped, AddTransient and AddSingleton?"  
author: "Magdalena Michalska"  
published: 2026-11-13  
updated: 2026-11-13  
canonical: https://www.mindstick.com/forum/163003/what-is-the-difference-between-addscoped-addtransient-and-addsingleton  
category: "C# and .NET"  
tags: ["dependency-injection", "service lifetime", "asp.net core", "AddScoped", "AddSingleton"]  
reading_time: 1 minute  

---

# What is the difference between AddScoped, AddTransient and AddSingleton?

I always use AddScoped because the tutorial did. When would I need the other two?

## Replies

### Reply by Laura Larsen

The three methods control how long an object lives:

- **Transient**: a new instance every time it is requested. Good for small, stateless helpers.
- **Scoped**: one instance per scope, which in a web app means per HTTP request. The usual choice for services that use a database context.
- **Singleton**: one instance for the whole life of the app. Use it for caches, configuration and expensive objects. It must be thread-safe, because many requests share it.

Rules that prevent bugs:

- A singleton must not depend on a scoped service. The scoped object would be kept alive far longer than intended.
- Never keep per-user data in a singleton field.
- DbContext should be scoped, not singleton.

So AddScoped is a sensible default for request work, but caches and clients such as HttpClient factories fit singleton or transient better.


---

Original Source: https://www.mindstick.com/forum/163003/what-is-the-difference-between-addscoped-addtransient-and-addsingleton

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
