Demka_kur/Hardik/Conect/Conector.cs
2025-03-07 09:51:43 +03:00

34 lines
1.3 KiB
C#

using Demka_Snova_1.Hardik.Conect.Dao;
using Microsoft.EntityFrameworkCore;
namespace Demka_Snova_1.Hardik.Conect;
public class AppDbContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder oB)
{
oB.UseSqlServer("Server=45.67.56.214,5421;Database=user16;User=user16;Password=dZ28IVE5;");
}
public DbSet<SotrudnikDao> sotrudnik { get; set; }
public DbSet<uslugiDao> uslugi { get; set; }
public DbSet<ordersDao> orders { get; set; }
public DbSet<KlientDao> klient { get; set; }
public DbSet<historyDao> history { get; set; }
protected override void OnModelCreating(ModelBuilder mb)
{
mb.Entity<KlientDao>().ToTable("Klient", "Demo_Blago").HasKey(klient => klient.Code);
mb.Entity<KlientDao>().Property(klient => klient.Code).ValueGeneratedOnAdd();
mb.Entity<ordersDao>().ToTable("orders", "Demo_Blago").HasKey(orders => orders.ID);
mb.Entity<ordersDao>().Property(orders => orders.ID).ValueGeneratedOnAdd();
mb.Entity<uslugiDao>().ToTable("uslugi", "Demo_Blago").HasKey(uslugi => uslugi.id);
mb.Entity<SotrudnikDao>().ToTable("Sotrudnik", "Demo_Blago").HasKey(sotrudnik => sotrudnik.ID);
mb.Entity<historyDao>().ToTable("history", "Demo_Blago").HasKey(history => history.id);
}
}