언어

EntityFrameworkServiceCollectionExtensions.ConfigureDbContext 메서드

정의

오버로드

ConfigureDbContext<TContext>(IServiceCollection, Action<IServiceProvider,DbContextOptionsBuilder>, ServiceLifetime)

Source:
EntityFrameworkServiceCollectionExtensions.cs
Source:
EntityFrameworkServiceCollectionExtensions.cs
Source:
EntityFrameworkServiceCollectionExtensions.cs

에서 지정된 컨텍스트 형식을 IServiceCollection구성합니다.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection ConfigureDbContext<TContext>(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, Action<IServiceProvider,Microsoft.EntityFrameworkCore.DbContextOptionsBuilder> optionsAction, Microsoft.Extensions.DependencyInjection.ServiceLifetime optionsLifetime = Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton) where TContext : Microsoft.EntityFrameworkCore.DbContext;
static member ConfigureDbContext : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<IServiceProvider, Microsoft.EntityFrameworkCore.DbContextOptionsBuilder> * Microsoft.Extensions.DependencyInjection.ServiceLifetime -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)
<Extension()>
Public Function ConfigureDbContext(Of TContext As DbContext) (serviceCollection As IServiceCollection, optionsAction As Action(Of IServiceProvider, DbContextOptionsBuilder), Optional optionsLifetime As ServiceLifetime = Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton) As IServiceCollection

형식 매개 변수

TContext

등록할 컨텍스트의 형식입니다.

매개 변수

serviceCollection
IServiceCollection

IServiceCollection 서비스를 추가할 수 있습니다.

optionsAction
Action<IServiceProvider,DbContextOptionsBuilder>

컨텍스트에 대해 구성하는 DbContextOptions 작업입니다.

optionsLifetime
ServiceLifetime

서비스가 컨테이너에 DbContextOptions 등록되는 수명입니다.

반품

여러 호출을 연결할 수 있도록 동일한 서비스 컬렉션입니다.

설명

AddDbContext<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime, ServiceLifetime), AddDbContextPool<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, Int32)AddDbContextFactory<TContext,TFactory>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime) 또는 AddPooledDbContextFactory<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, Int32) 지정된 구성을 적용하려면 호출해야 합니다. 위의 구성 이후에 이 메서드를 호출하면 충돌하는 구성이 ovewrite됩니다. 풀되지 않은 컨텍스트의 OnConfiguring(DbContextOptionsBuilder) 경우 여기에서 수행되는 구성 외에도 구성이 적용됩니다.

이 메서드는 여러 번 호출할 수 있으며 지정된 순서로 구성이 적용됩니다.

자세한 내용 및 예제는 종속성 주입과 함께 DbContext 사용을 참조하세요.

적용 대상

ConfigureDbContext<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime)

Source:
EntityFrameworkServiceCollectionExtensions.cs
Source:
EntityFrameworkServiceCollectionExtensions.cs
Source:
EntityFrameworkServiceCollectionExtensions.cs

에서 지정된 컨텍스트 형식을 IServiceCollection구성합니다.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection ConfigureDbContext<TContext>(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, Action<Microsoft.EntityFrameworkCore.DbContextOptionsBuilder> optionsAction, Microsoft.Extensions.DependencyInjection.ServiceLifetime optionsLifetime = Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton) where TContext : Microsoft.EntityFrameworkCore.DbContext;
static member ConfigureDbContext : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.EntityFrameworkCore.DbContextOptionsBuilder> * Microsoft.Extensions.DependencyInjection.ServiceLifetime -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)
<Extension()>
Public Function ConfigureDbContext(Of TContext As DbContext) (serviceCollection As IServiceCollection, optionsAction As Action(Of DbContextOptionsBuilder), Optional optionsLifetime As ServiceLifetime = Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton) As IServiceCollection

형식 매개 변수

TContext

등록할 컨텍스트의 형식입니다.

매개 변수

serviceCollection
IServiceCollection

IServiceCollection 서비스를 추가할 수 있습니다.

optionsAction
Action<DbContextOptionsBuilder>

컨텍스트에 대해 구성하는 DbContextOptions 작업입니다.

optionsLifetime
ServiceLifetime

서비스가 컨테이너에 DbContextOptions 등록되는 수명입니다.

반품

여러 호출을 연결할 수 있도록 동일한 서비스 컬렉션입니다.

설명

AddDbContext<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime, ServiceLifetime), AddDbContextPool<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, Int32)AddDbContextFactory<TContext,TFactory>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime) 또는 AddPooledDbContextFactory<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, Int32) 지정된 구성을 적용하려면 호출해야 합니다. 위의 구성 이후에 이 메서드를 호출하면 충돌하는 구성이 ovewrite됩니다. 풀되지 않은 컨텍스트의 OnConfiguring(DbContextOptionsBuilder) 경우 여기에서 수행되는 구성 외에도 구성이 적용됩니다.

이 메서드는 여러 번 호출할 수 있으며 지정된 순서로 구성이 적용됩니다.

자세한 내용 및 예제는 종속성 주입과 함께 DbContext 사용을 참조하세요.

적용 대상