private void UpdateDatabase(bool delete) { using (var serviceScope = _serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope()) { var dbContext = serviceScope.ServiceProvider.GetService <ScbDbContext>(); if (delete) { dbContext.Database.EnsureDeleted(); } try { Directory.CreateDirectory(ScbHelper.GetScbDatabaseDirectory(_configuration)); if (dbContext.Database.GetPendingMigrations().Any()) { dbContext.Database.Migrate(); } } catch (Exception) { throw; } } }
public ScbNewBornApiClient(IConfiguration configuration) : base(configuration, ScbHelper.GetScbUri(configuration)) { }
protected override void OnConfiguring(DbContextOptionsBuilder options) { options.UseSqlite($"{DataSource}={ScbHelper.GetScbDatabasePath(configuration)}"); }