transient lifetime
A service lifetime in which the container creates a new instance every time the service is requested.
In more detail
It is registered with AddTransient. It suits lightweight, stateless services such as a clock or formatter.
Related terms
- service lifetime — How long the container keeps and reuses an instance of a service: transient, scoped or singleton.
- scoped lifetime — A service lifetime in which one instance is shared within a scope, which in ASP.NET Core means one HTTP request, then disposed.
- singleton — A service lifetime, or design, in which one instance is created and shared for the whole life of the process.
Taught in
- The Dependency Injection Container: Scopes and Lifetimes — Modern .NET Core, C# & Enterprise Microservices