Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

ServiceLifetime Enum

Definition

Namespace:
Microsoft.Extensions.DependencyInjection
Assembly:
Microsoft.Extensions.DependencyInjection.Abstractions.dll
Package:
Microsoft.Extensions.DependencyInjection.Abstractions v11.0.0-preview.5.26302.115
Source:
ServiceLifetime.cs
Source:
ServiceLifetime.cs
Source:
ServiceLifetime.cs
Source:
ServiceLifetime.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Specifies the lifetime of a service in an IServiceCollection.

public enum class ServiceLifetime
public enum ServiceLifetime
type ServiceLifetime = 
Public Enum ServiceLifetime
Inheritance
ServiceLifetime

Fields

Name Value Description
Singleton 0

Specifies that a single instance of the service will be created.

Scoped 1

Specifies that a new instance of the service will be created for each scope.

Transient 2

Specifies that a new instance of the service will be created every time it is requested.

Applies to


Feedback

Was this page helpful?