public PrefsDb(string dbPath) { var optionsBuilder = new DbContextOptionsBuilder <PreferencesDbContext>(); optionsBuilder.UseSqlite($"Data Source={dbPath}"); _prefsCtx = new PreferencesDbContext(optionsBuilder.Options); _prefsCtx.Database.Migrate(); }
public PrefsDb(IDatabaseConfiguration dbConfig) { _prefsCtx = dbConfig switch { SqliteConfiguration sqlite => (PreferencesDbContext) new SqlitePreferencesDbContext( sqlite.Options), PostgresConfiguration postgres => new PostgresPreferencesDbContext(postgres.Options), _ => throw new NotImplementedException() }; _prefsCtx.Database.Migrate(); }