db + migrations

This commit is contained in:
Aleksandr Popov
2023-06-25 18:33:44 +02:00
parent 944712df97
commit 34acef713d
14 changed files with 255 additions and 172 deletions
@@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore;
namespace TURN.Services.Chess.DBModel
{
public partial class ModelBaseContext : DbContext
{
public ModelBaseContext()
{
}
public ModelBaseContext(DbContextOptions<ModelBaseContext> options)
: base(options)
{
}
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 OnModelCreating(ModelBuilder modelBuilder)
{
_ = modelBuilder.Entity<Game>(entity =>
{
_ = entity.HasKey(e => e.GameId);
_ = entity.Property(e => e.GameId)
.ValueGeneratedOnAdd()
.HasColumnName("GameId");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
}