Bahasa

PooledDbContextFactory<TContext> Kelas

Definisi

Pabrik yang mengembalikan instans terkumpul DbContext . Membuang instans yang dikembalikan oleh pabrik ini mengembalikannya ke mekanisme pengumpulan internal.

[System.Runtime.CompilerServices.Nullable(0)]
public class PooledDbContextFactory<TContext> : Microsoft.EntityFrameworkCore.IDbContextFactory<TContext> where TContext : DbContext
public class PooledDbContextFactory<TContext> : Microsoft.EntityFrameworkCore.IDbContextFactory<TContext> where TContext : DbContext
[<System.Runtime.CompilerServices.Nullable(0)>]
type PooledDbContextFactory<'Context (requires 'Context :> DbContext)> = class
    interface IDbContextFactory<'Context (requires 'Context :> DbContext)>
type PooledDbContextFactory<'Context (requires 'Context :> DbContext)> = class
    interface IDbContextFactory<'Context (requires 'Context :> DbContext)>
Public Class PooledDbContextFactory(Of TContext)
Implements IDbContextFactory(Of TContext)

Jenis parameter

TContext
Warisan
PooledDbContextFactory<TContext>
Atribut
Penerapan

Keterangan

Layanan jenis ini terdaftar dalam kontainer injeksi dependensi dengan EntityFrameworkServiceCollectionExtensions.AddDbContextPool metode .

Lihat Menggunakan DbContext dengan injeksi dependensi, Menggunakan pabrik DbContext, dan Menggunakan pengumpulan DbContext untuk informasi dan contoh selengkapnya.

Konstruktor

Nama Deskripsi
PooledDbContextFactory<TContext>(DbContextOptions<TContext>, Int32)

Menginisialisasi instans baru dari kelas PooledDbContextFactory<TContext>.

PooledDbContextFactory<TContext>(IDbContextPool<TContext>)

Ini adalah API internal yang mendukung infrastruktur Entity Framework Core dan tidak tunduk pada standar kompatibilitas yang sama dengan API publik. Ini dapat diubah atau dihapus tanpa pemberitahuan dalam rilis apa pun. Anda hanya boleh menggunakannya langsung dalam kode Anda dengan sangat hati-hati dan mengetahui bahwa melakukannya dapat mengakibatkan kegagalan aplikasi saat memperbarui ke rilis Entity Framework Core baru.

Metode

Nama Deskripsi
CreateDbContext()

Membuat instans DbContext baru.

CreateDbContextAsync(CancellationToken)

Membuat instans baru DbContext dalam konteks asinkron.

Berlaku untuk