private DatabaseService(DbOptions options) { _options = options; switch (_options.DbType) { case DbTypeEnym.MySQL: _dbConnectionConfig = new MysqlDBConnectionConfig(_options.ConnectionString); break; case DbTypeEnym.SQLite: _dbConnectionConfig = new SqliteDBConnectionConfig(_options.ConnectionString); break; default: throw new NotImplementedException($"Database type {_options.DbType} not configured"); } using (var context = new AppDbContext(_dbConnectionConfig)) { context.Database.EnsureCreated(); } }
public AppDbContext(IDatabaseConnectionConfig connectionConfig) { _connectionConfig = connectionConfig; }
public AppDbContext() { _connectionConfig = new SqliteDBConnectionConfig("DataSource=ServerApi.db"); }