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
servicesIServiceCollectionThe IServiceCollection to add the
TContextandTFactoryto.connectionStringstringThe connection string to use for the
TContext.applicationRoleNamestringThe application role name for the
TContext.applicationRolePasswordstringThe application role password for the
TContext.
Returns
- IServiceCollection
The IServiceCollection for further configuration.
Type Parameters
TContextThe type of the DbContext.
TFactoryInterfaceThe type of the IDbContextFactory<TContext> interface.
TFactoryThe 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
servicesIServiceCollectionThe IServiceCollection to add the
TContextandTFactoryto.connectionStringstringThe connection string to use for the
TContext.
Returns
- IServiceCollection
The IServiceCollection for further configuration.
Type Parameters
TContextThe type of the DbContext.
TFactoryInterfaceThe type of the IDbContextFactory<TContext> interface.
TFactoryThe 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
servicesIServiceCollectionThe IServiceCollection to add the
TContextandTFactoryto.sqlConnectionOptionISqlConnectionOptionThe SQL connection option to use for the
TContext.
Returns
- IServiceCollection
The IServiceCollection for further configuration.
Type Parameters
TContextThe type of the DbContext.
TFactoryInterfaceThe type of the IDbContextFactory<TContext> interface.
TFactoryThe 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
servicesIServiceCollectionThe IServiceCollection to add the
TContextandTFactoryto.optionsActionAction<DbContextOptionsBuilder>An optional action to configure the DbContextOptionsBuilder.
Returns
- DbContextOptionsBuilder
The DbContextOptionsBuilder for further configuration.
Type Parameters
TContextThe type of the DbContext.
TFactoryInterfaceThe type of the IDbContextFactory<TContext> interface.
TFactoryThe type of the IDbContextFactory<TContext> implementation.