Demka_kur/Hardik/Conect/Conector.cs

32 lines
1.1 KiB
C#
Raw Permalink Normal View History

2025-02-04 11:35:26 +00:00
using Microsoft.EntityFrameworkCore;
using Demka_Snova_1.Hardik.Conect.Dao;
namespace Demka_Snova_1.Hardik.Conect;
public class AppDbContext : DbContext
{
2025-02-04 12:40:01 +00:00
protected override void OnConfiguring(DbContextOptionsBuilder oB)
{
2025-02-05 10:03:38 +00:00
oB.UseSqlServer("Hoi");
2025-02-04 12:40:01 +00:00
}
2025-02-04 11:35:26 +00:00
public DbSet<SotrudnikDao> sotrudnik { get; set; }
2025-02-04 12:40:01 +00:00
public DbSet<uslugiDao> uslugi { get; set; }
public DbSet<ordersDao> orders { get; set; }
public DbSet<KlientDao> klient { get; set; }
2025-02-05 10:03:38 +00:00
public DbSet<historyDao> history { get; set; }
2025-02-04 11:35:26 +00:00
2025-02-04 12:40:01 +00:00
protected override void OnModelCreating(ModelBuilder mb)
2025-02-04 11:35:26 +00:00
{
2025-02-04 12:40:01 +00:00
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);
2025-02-05 10:03:38 +00:00
mb.Entity<historyDao>().HasKey(history => history.id);
2025-02-04 11:35:26 +00:00
}
2025-02-04 12:40:01 +00:00
2025-02-04 11:35:26 +00:00
}