Example #1
0
        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();
            }
        }
Example #2
0
 public AppDbContext(IDatabaseConnectionConfig connectionConfig)
 {
     _connectionConfig = connectionConfig;
 }
Example #3
0
 public AppDbContext()
 {
     _connectionConfig = new SqliteDBConnectionConfig("DataSource=ServerApi.db");
 }