editorconfig added,

modelbuilder fix for local connString
This commit is contained in:
Aleksandr Popov
2023-06-26 08:58:42 +02:00
parent cd2605efe3
commit 171b640230
8 changed files with 506 additions and 19 deletions
@@ -15,10 +15,20 @@ namespace TURN.Services.Chess.DBModel
public virtual DbSet<Game> Games { get; set; }
//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
//{
// _ = optionsBuilder.UseNpgsql("Server=localhost;Port=5432;Database=TURNChess;UserId=postgres;Password=example;");
//}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
try
{
_ = Environment.GetEnvironmentVariable("DB") != null
? optionsBuilder.UseNpgsql(Environment.GetEnvironmentVariable("DB"))
: optionsBuilder.UseNpgsql("Server=localhost;Port=5432;Database=TURNChess;UserId=postgres;" +
"Password=example;");
}
catch (Exception)
{
_ = optionsBuilder.UseNpgsql("Server=localhost;Port=5432;Database=TURNChess;UserId=postgres;Password=example;");
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{