public void ConfigureDevelopmentServices(IServiceCollection services) { var appSettings = this.getSettings(services); var secretAppSettings = new SecretAppSettings(Configuration, appSettings); // For development env, it use in memory database services.ConfigureDbContext(secretAppSettings, development: true); ConfigureServices(services); }
public void ConfigureProductionServices(IServiceCollection services) { var appSettings = this.getSettings(services); var secretAppSettings = new SecretAppSettings(Configuration, appSettings); // For producation env, it use SQL database. // TODO: add connection string for data/identity in App settings. // TODO: support azure key vault support. services.ConfigureDbContext(secretAppSettings, development: false); ConfigureServices(services); }
public static void ConfigureDbContext(this IServiceCollection services, SecretAppSettings secretAppSettings, bool development = false) { if (development) { services.AddDbContext <AppIdentityDbContext>( options => options.UseInMemoryDatabase("Identity") ); } else { services.AddDbContext <AppIdentityDbContext>( options => options.UseSqlServer(secretAppSettings.IdentityConnectionString) ); } }