EntityFrameworkServiceCollectionExtensions.ConfigureDbContext 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
오버로드
ConfigureDbContext<TContext>(IServiceCollection, Action<IServiceProvider,DbContextOptionsBuilder>, ServiceLifetime)
에서 지정된 컨텍스트 형식을 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)
에서 지정된 컨텍스트 형식을 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 사용을 참조하세요.