33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
|
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();
|
||
|
}
|
||
|
}
|