private static void PreConfigure <TDbContext>( EPTDbContextOptions options, DbContextConfigurationContext <TDbContext> context) where TDbContext : EPTDbContext <TDbContext> { foreach (var defaultPreConfigureAction in options.DefaultPreConfigureActions) { defaultPreConfigureAction.Invoke(context); } var preConfigureActions = options.PreConfigureActions.GetOrDefault(typeof(TDbContext)); if (!preConfigureActions.IsNullOrEmpty()) { foreach (var preConfigureAction in preConfigureActions) { ((Action <DbContextConfigurationContext <TDbContext> >)preConfigureAction).Invoke(context); } } }
private static void Configure <TDbContext>( EPTDbContextOptions options, DbContextConfigurationContext <TDbContext> context) where TDbContext : EPTDbContext <TDbContext> { var configureAction = options.ConfigureActions.GetOrDefault(typeof(TDbContext)); if (configureAction != null) { ((Action <DbContextConfigurationContext <TDbContext> >)configureAction).Invoke(context); } else if (options.DefaultConfigureAction != null) { options.DefaultConfigureAction.Invoke(context); } else { throw new EPTException( $"No configuration found for {typeof(DbContext).AssemblyQualifiedName}! Use services.Configure<EPTDbContextOptions>(...) to configure it."); } }