db + migrations
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user