EntityFrameworkServiceCollectionExtensions.ConfigureDbContext Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Aşırı Yüklemeler
| Veri Akışı Adı | Description |
|---|---|
| ConfigureDbContext<TContext>(IServiceCollection, Action<IServiceProvider,DbContextOptionsBuilder>, ServiceLifetime) |
içinde verilen bağlam türünü yapılandırıyor IServiceCollection. |
| ConfigureDbContext<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime) |
içinde verilen bağlam türünü yapılandırıyor IServiceCollection. |
ConfigureDbContext<TContext>(IServiceCollection, Action<IServiceProvider,DbContextOptionsBuilder>, ServiceLifetime)
içinde verilen bağlam türünü yapılandırıyor 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
Tür Parametreleri
- TContext
Kaydedilecek bağlam türü.
Parametreler
- serviceCollection
- IServiceCollection
IServiceCollection için hizmetler eklenir.
- optionsAction
- Action<IServiceProvider,DbContextOptionsBuilder>
bağlamını yapılandırmak DbContextOptions için bir eylem.
- optionsLifetime
- ServiceLifetime
Hizmetin kapsayıcıya DbContextOptions kaydedileceği yaşam süresi.
Döndürülenler
Birden çok çağrının zincirlenebilmesi için aynı hizmet koleksiyonu.
Açıklamalar
AddDbContext<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime, ServiceLifetime), AddDbContextPool<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, Int32)AddDbContextFactory<TContext,TFactory>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime) veya AddPooledDbContextFactory<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, Int32) belirtilen yapılandırmanın etkili olması için de çağrılmalıdır. Yukarıdakilerden herhangi birinin ardından bu yöntemin çağrılması çakışan yapılandırmayı ortaya çıkaracaktır. Havuza alınamayan bağlamlar OnConfiguring(DbContextOptionsBuilder) için yapılandırma, burada gerçekleştirilen yapılandırmaya ek olarak uygulanır.
Bu yöntem birden çok kez çağrılabilir ve yapılandırma belirtilen sırayla uygulanır.
Daha fazla bilgi ve örnek için bkz. DbContext'i bağımlılık ekleme ile kullanma .
Şunlara uygulanır
ConfigureDbContext<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime)
içinde verilen bağlam türünü yapılandırıyor 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
Tür Parametreleri
- TContext
Kaydedilecek bağlam türü.
Parametreler
- serviceCollection
- IServiceCollection
IServiceCollection için hizmetler eklenir.
- optionsAction
- Action<DbContextOptionsBuilder>
bağlamını yapılandırmak DbContextOptions için bir eylem.
- optionsLifetime
- ServiceLifetime
Hizmetin kapsayıcıya DbContextOptions kaydedileceği yaşam süresi.
Döndürülenler
Birden çok çağrının zincirlenebilmesi için aynı hizmet koleksiyonu.
Açıklamalar
AddDbContext<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime, ServiceLifetime), AddDbContextPool<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, Int32)AddDbContextFactory<TContext,TFactory>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime) veya AddPooledDbContextFactory<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, Int32) belirtilen yapılandırmanın etkili olması için de çağrılmalıdır. Yukarıdakilerden herhangi birinin ardından bu yöntemin çağrılması çakışan yapılandırmayı ortaya çıkaracaktır. Havuza alınamayan bağlamlar OnConfiguring(DbContextOptionsBuilder) için yapılandırma, burada gerçekleştirilen yapılandırmaya ek olarak uygulanır.
Bu yöntem birden çok kez çağrılabilir ve yapılandırma belirtilen sırayla uygulanır.
Daha fazla bilgi ve örnek için bkz. DbContext'i bağımlılık ekleme ile kullanma .