Ejemplo n.º 1
0
        public PrefsDb(string dbPath)
        {
            var optionsBuilder = new DbContextOptionsBuilder <PreferencesDbContext>();

            optionsBuilder.UseSqlite($"Data Source={dbPath}");

            _prefsCtx = new PreferencesDbContext(optionsBuilder.Options);
            _prefsCtx.Database.Migrate();
        }
Ejemplo n.º 2
0
 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();
 }