public static void AddDataLayer(this IServiceCollection services, IConfiguration configuration) { services.Configure <DataLayerOptions>(DataLayerOptions.From(configuration)); services.AddDbContext <AppDbContext>(o => o.AddInterceptors(new QueryCommandInterceptor()), ServiceLifetime.Transient); services.AddSingleton <IDbContextFactory, DbContextFactory>(); }
public AppDbContext(IOptions <DataLayerOptions> options, ILoggerFactory loggerFactory) { _options = options.Value; _loggerFactory = loggerFactory; }