Method AddDbContextAndFactory
AddDbContextAndFactory<TContext, TFactoryInterface, TFactory>(IServiceCollection, string, string, string)
Adds the specified TContext
and TFactory
to the IServiceCollection as scoped services.
public static IServiceCollection AddDbContextAndFactory<TContext, TFactoryInterface, TFactory>(this IServiceCollection services, string connectionString, string applicationRoleName = "", string applicationRolePassword = "") where TContext : DbContext where TFactoryInterface : IDbContextFactory<TContext> where TFactory : IDbContextFactory<TContext>
Parameters
services
IServiceCollectionThe IServiceCollection to add the
TContext
andTFactory
to.connectionString
stringThe connection string to use for the
TContext
.applicationRoleName
stringThe application role name for the
TContext
.applicationRolePassword
stringThe application role password for the
TContext
.
Returns
- IServiceCollection
The IServiceCollection for further configuration.
Type Parameters
TContext
The type of the DbContext.
TFactoryInterface
The type of the IDbContextFactory<TContext> interface.
TFactory
The type of the IDbContextFactory<TContext> implementation.
AddDbContextAndFactory<TContext, TFactoryInterface, TFactory>(IServiceCollection, string)
Adds the specified TContext
and TFactory
to the IServiceCollection as scoped services.
public static IServiceCollection AddDbContextAndFactory<TContext, TFactoryInterface, TFactory>(this IServiceCollection services, string connectionString) where TContext : DbContext where TFactoryInterface : IDbContextFactory<TContext> where TFactory : IDbContextFactory<TContext>
Parameters
services
IServiceCollectionThe IServiceCollection to add the
TContext
andTFactory
to.connectionString
stringThe connection string to use for the
TContext
.
Returns
- IServiceCollection
The IServiceCollection for further configuration.
Type Parameters
TContext
The type of the DbContext.
TFactoryInterface
The type of the IDbContextFactory<TContext> interface.
TFactory
The type of the IDbContextFactory<TContext> implementation.
AddDbContextAndFactory<TContext, TFactoryInterface, TFactory>(IServiceCollection, ISqlConnectionOption)
Adds the specified TContext
and TFactory
to the IServiceCollection as scoped services.
public static IServiceCollection AddDbContextAndFactory<TContext, TFactoryInterface, TFactory>(this IServiceCollection services, ISqlConnectionOption sqlConnectionOption) where TContext : DbContext where TFactoryInterface : IDbContextFactory<TContext> where TFactory : IDbContextFactory<TContext>
Parameters
services
IServiceCollectionThe IServiceCollection to add the
TContext
andTFactory
to.sqlConnectionOption
ISqlConnectionOptionThe SQL connection option to use for the
TContext
.
Returns
- IServiceCollection
The IServiceCollection for further configuration.
Type Parameters
TContext
The type of the DbContext.
TFactoryInterface
The type of the IDbContextFactory<TContext> interface.
TFactory
The type of the IDbContextFactory<TContext> implementation.
AddDbContextAndFactory<TContext, TFactoryInterface, TFactory>(IServiceCollection, Action<DbContextOptionsBuilder>)
Adds the specified TContext
and TFactory
to the IServiceCollection as scoped services.
public static DbContextOptionsBuilder AddDbContextAndFactory<TContext, TFactoryInterface, TFactory>(this IServiceCollection services, Action<DbContextOptionsBuilder> optionsAction = null) where TContext : DbContext where TFactoryInterface : IDbContextFactory<TContext> where TFactory : IDbContextFactory<TContext>
Parameters
services
IServiceCollectionThe IServiceCollection to add the
TContext
andTFactory
to.optionsAction
Action<DbContextOptionsBuilder>An optional action to configure the DbContextOptionsBuilder.
Returns
- DbContextOptionsBuilder
The DbContextOptionsBuilder for further configuration.
Type Parameters
TContext
The type of the DbContext.
TFactoryInterface
The type of the IDbContextFactory<TContext> interface.
TFactory
The type of the IDbContextFactory<TContext> implementation.