Demka_kur/Hardik/Conect/Conector.cs
2025-02-04 15:40:01 +03:00

29 lines
1.0 KiB
C#

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