LootBoxGenerator/LootBoxSimulator/Models/DAO/RemoteDatabaseContext.cs

33 lines
1.1 KiB
C#
Raw Permalink Normal View History

2024-12-05 11:29:52 +00:00
using Microsoft.EntityFrameworkCore;
namespace LootBoxSimulator.Models.DAO;
public class RemoteDatabaseContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Username=postgres;Password=123");
}
public DbSet<ItemDao> Items { get; set; }
public DbSet<RateDao> Rates { get; set; }
public DbSet<CategoryDao> Categories { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ItemDao>()
.HasKey(x => x.Id);
modelBuilder.Entity<ItemDao>()
.Property(x => x.Id)
.ValueGeneratedOnAdd();
modelBuilder.Entity<RateDao>()
.HasKey(x => x.Id);
modelBuilder.Entity<CategoryDao>()
.Property(x => x.Id)
.ValueGeneratedOnAdd();
modelBuilder.Entity<CategoryDao>()
.HasKey(x => x.Id);
modelBuilder.Entity<RateDao>()
.Property(x => x.Id)
.ValueGeneratedOnAdd();
}
}