Class DbContextFactory<TContext>
- Namespace
- Microsoft.EntityFrameworkCore.Internal
- Assembly
- Microsoft.EntityFrameworkCore.dll
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public class DbContextFactory<TContext> : IDbContextFactory<TContext> where TContext : DbContext
Type Parameters
TContext
- Inheritance
-
DbContextFactory<TContext>
- Implements
-
IDbContextFactory<TContext>
- Inherited Members
Constructors
DbContextFactory(IServiceProvider, DbContextOptions<TContext>, IDbContextFactorySource<TContext>)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public DbContextFactory(IServiceProvider serviceProvider, DbContextOptions<TContext> options, IDbContextFactorySource<TContext> factorySource)
Parameters
serviceProvider
IServiceProvideroptions
DbContextOptions<TContext>factorySource
IDbContextFactorySource<TContext>
Methods
CreateDbContext()
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public virtual TContext CreateDbContext()
Returns
- TContext
CreateDbContextAsync(CancellationToken)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public virtual Task<TContext> CreateDbContextAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationToken
Returns
- Task<TContext>