public static IConfigurationBuilder AddEntityFameworkValues(this IConfigurationBuilder builder, Action <EfConfgurationOptions> optionsAction = null) { //build the configuration up to this point var connectionStringConfig = builder.Build(); //set the default settings var efOptions = new EfConfgurationOptions { ConnectionStringName = "DefaultConnection", PollingInterval = 1000 }; //invoke user customized settings optionsAction?.Invoke(efOptions); //configure entity framework to use SqlServer var dbOptions = new DbContextOptionsBuilder <ConfigurationContext>(); var migrationsAssembly = typeof(EfConfigurationExtensions).GetTypeInfo().Assembly.GetName().Name; dbOptions = dbOptions.UseSqlServer( connectionStringConfig.GetConnectionString(efOptions.ConnectionStringName), options => options.MigrationsAssembly(migrationsAssembly) ); //add our new database source for configuration items return(builder.Add(new EfConfigurationSource(dbOptions.Options, efOptions))); }
public EfConfigurationProvider(DbContextOptions <ConfigurationContext> dbOptions, EfConfgurationOptions efOptions) { _cancellationToken = new CancellationTokenSource(); _dbOptions = dbOptions; _efOptions = efOptions; }
/// <summary> /// Create a configuration source that returns configuration items from the database /// </summary> /// <param name="dbOptions">The Entity Framework Database Configuration</param> /// <param name="efOptions">The options to use for this source</param> public EfConfigurationSource(DbContextOptions <ConfigurationContext> dbOptions, EfConfgurationOptions efOptions) { _dbOptions = dbOptions; _efOptions = efOptions; }