EntityFrameworkServiceCollectionExtensions Class

Definition

Extension methods for setting up Entity Framework related services in an IServiceCollection.

public static class EntityFrameworkServiceCollectionExtensions
type EntityFrameworkServiceCollectionExtensions = class
Public Module EntityFrameworkServiceCollectionExtensions
Inheritance
EntityFrameworkServiceCollectionExtensions

Methods

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

Registers the given context as a service in the IServiceCollection. You use this method when using dependency injection in your application, such as with ASP.NET. For more information on setting up dependency injection, see http://go.microsoft.com/fwlink/?LinkId=526890.

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

Registers the given context as a service in the IServiceCollection.

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

Registers the given context as a service in the IServiceCollection. You use this method when using dependency injection in your application, such as with ASP.NET. For more information on setting up dependency injection, see http://go.microsoft.com/fwlink/?LinkId=526890.

This overload has an optionsAction that provides the applications IServiceProvider. This is useful if you want to setup Entity Framework to resolve its internal services from the primary application service provider. By default, we recommend using the other overload, which allows Entity Framework to create and maintain its own IServiceProvider for internal Entity Framework services.

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

Registers the given context as a service in the IServiceCollection.

AddDbContext<TContext>(IServiceCollection, ServiceLifetime)

Registers the given context as a service in the IServiceCollection. You use this method when using dependency injection in your application, such as with ASP.NET. For more information on setting up dependency injection, see http://go.microsoft.com/fwlink/?LinkId=526890.

AddDbContext<TContext>(IServiceCollection, ServiceLifetime, ServiceLifetime)

Registers the given context as a service in the IServiceCollection.

AddDbContext<TContextService,TContextImplementation>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime, ServiceLifetime)

Registers the given context as a service in the IServiceCollection.

AddDbContext<TContextService,TContextImplementation>(IServiceCollection, Action<IServiceProvider,DbContextOptionsBuilder>, ServiceLifetime, ServiceLifetime)

Registers the given context as a service in the IServiceCollection.

AddDbContext<TContextService,TContextImplementation>(IServiceCollection, ServiceLifetime, ServiceLifetime)

Registers the given context as a service in the IServiceCollection.

AddDbContextFactory<TContext,TFactory>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime)

Registers an IDbContextFactory<TContext> in the IServiceCollection to create instances of given DbContext type.

AddDbContextFactory<TContext,TFactory>(IServiceCollection, Action<IServiceProvider,DbContextOptionsBuilder>, ServiceLifetime)

Registers an IDbContextFactory<TContext> in the IServiceCollection to create instances of given DbContext type.

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

Registers an IDbContextFactory<TContext> in the IServiceCollection to create instances of given DbContext type.

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

Registers an IDbContextFactory<TContext> in the IServiceCollection to create instances of given DbContext type.

AddDbContextPool<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, Int32)

Registers the given DbContext as a service in the IServiceCollection, and enables DbContext pooling for this registration.

AddDbContextPool<TContext>(IServiceCollection, Action<IServiceProvider,DbContextOptionsBuilder>, Int32)

Registers the given DbContext as a service in the IServiceCollection, and enables DbContext pooling for this registration.

AddDbContextPool<TContextService,TContextImplementation>(IServiceCollection, Action<DbContextOptionsBuilder>, Int32)

Registers the given DbContext as a service in the IServiceCollection, and enables DbContext pooling for this registration.

AddDbContextPool<TContextService,TContextImplementation>(IServiceCollection, Action<IServiceProvider,DbContextOptionsBuilder>, Int32)

Registers the given DbContext as a service in the IServiceCollection, and enables DbContext pooling for this registration.

AddPooledDbContextFactory<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, Int32)

Registers an IDbContextFactory<TContext> in the IServiceCollection to create instances of given DbContext type where instances are pooled for reuse.

AddPooledDbContextFactory<TContext>(IServiceCollection, Action<IServiceProvider,DbContextOptionsBuilder>, Int32)

Registers an IDbContextFactory<TContext> in the IServiceCollection to create instances of given DbContext type where instances are pooled for reuse.

Applies to