/// <summary> /// Pres the configure. /// </summary> /// <typeparam name="TDbContext">The type of the t database context.</typeparam> /// <param name="options">The options.</param> /// <param name="context">The context.</param> private static void PreConfigure <TDbContext>( EfCoreDbContextOptions options, DbContextConfigurationContext <TDbContext> context) where TDbContext : EfCoreDbContext <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); } } }
/// <summary> /// Configures the specified options. /// </summary> /// <typeparam name="TDbContext">The type of the t database context.</typeparam> /// <param name="options">The options.</param> /// <param name="context">The context.</param> /// <exception cref="Exception">No configuration found for {typeof(DbContext).AssemblyQualifiedName}! Use services.Configure<AbpDbContextOptions>(...) to configure it.</exception> private static void Configure <TDbContext>( EfCoreDbContextOptions options, DbContextConfigurationContext <TDbContext> context) where TDbContext : EfCoreDbContext <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 Exception( $"No configuration found for {typeof(DbContext).AssemblyQualifiedName}! Use services.Configure<AbpDbContextOptions>(...) to configure it."); } }