public static void UseMySQL( [NotNull] this QfDbContextOptions options, [CanBeNull] Action <MySqlDbContextOptionsBuilder> mySQLOptionsAction = null) { options.PreConfigure(context => { context.DbContextOptions.ConfigureWarnings(warnings => warnings.Ignore(CoreEventId.LazyLoadOnDisposedContextWarning)); }); options.Configure(context => { context.UseMySQL(mySQLOptionsAction); }); }
public static void UseSqlServer <TDbContext>( [NotNull] this QfDbContextOptions options, [CanBeNull] Action <SqlServerDbContextOptionsBuilder> sqlServerOptionsAction = null) where TDbContext : QfDbContext <TDbContext> { options.PreConfigure(context => { context.DbContextOptions.ConfigureWarnings(warnings => warnings.Ignore(CoreEventId.LazyLoadOnDisposedContextWarning)); }); options.Configure <TDbContext>(context => { context.UseSqlServer(sqlServerOptionsAction); }); }
private static void PreConfigure <TDbContext>( QfDbContextOptions options, DbContextConfigurationContext <TDbContext> context) where TDbContext : QfDbContext <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>( QfDbContextOptions options, DbContextConfigurationContext <TDbContext> context) where TDbContext : QfDbContext <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<AbpDbContextOptions>(...) to configure it."); } }