Table of Contents

Method AddDbContextAndFactory

Namespace
Innova.Data.Entity
Assembly
Innova.Data.dll

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 IServiceCollection

The IServiceCollection to add the TContext and TFactory to.

connectionString string

The connection string to use for the TContext.

applicationRoleName string

The application role name for the TContext.

applicationRolePassword string

The 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 IServiceCollection

The IServiceCollection to add the TContext and TFactory to.

connectionString string

The 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 IServiceCollection

The IServiceCollection to add the TContext and TFactory to.

sqlConnectionOption ISqlConnectionOption

The 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 IServiceCollection

The IServiceCollection to add the TContext and TFactory 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.