One instance is created per ServiceScope. The same instance is returned for every resolution within that scope.
Use for services that should be shared within a single unit of work (e.g. an HTTP request) but isolated between units.
One instance is created for the entire lifetime of the ServiceProvider. All subsequent resolutions return the same instance.
Use for expensive-to-create or truly global services (loggers, configuration, connection pools).
A new instance is created every time the service is resolved.
Use for lightweight, stateless services.
Defines the lifetime of a service within the dependency injection container.
The lifetime determines when a new instance is created versus when a cached instance is returned.
Example
See
ServiceCollection