Demka_kur/Hardik/Conect/Conector.cs

34 lines
1.3 KiB
C#
Raw Normal View History

2025-02-11 10:23:14 +00:00
using Demka_Snova_1.Hardik.Conect.Dao;
2025-03-05 09:12:58 +00:00
using Microsoft.EntityFrameworkCore;
2025-02-11 10:23:14 +00:00
namespace Demka_Snova_1.Hardik.Conect;
public class AppDbContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder oB)
{
2025-02-12 07:50:05 +00:00
oB.UseSqlServer("Server=45.67.56.214,5421;Database=user16;User=user16;Password=dZ28IVE5;");
2025-02-11 10:23:14 +00:00
}
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)
{
2025-03-07 06:51:43 +00:00
mb.Entity<KlientDao>().ToTable("Klient", "Demo_Blago").HasKey(klient => klient.Code);
2025-02-11 10:23:14 +00:00
mb.Entity<KlientDao>().Property(klient => klient.Code).ValueGeneratedOnAdd();
2025-03-05 09:12:58 +00:00
2025-03-07 06:51:43 +00:00
mb.Entity<ordersDao>().ToTable("orders", "Demo_Blago").HasKey(orders => orders.ID);
2025-02-11 10:23:14 +00:00
mb.Entity<ordersDao>().Property(orders => orders.ID).ValueGeneratedOnAdd();
2025-03-05 09:12:58 +00:00
2025-03-07 06:51:43 +00:00
mb.Entity<uslugiDao>().ToTable("uslugi", "Demo_Blago").HasKey(uslugi => uslugi.id);
2025-03-05 09:12:58 +00:00
2025-03-07 06:51:43 +00:00
mb.Entity<SotrudnikDao>().ToTable("Sotrudnik", "Demo_Blago").HasKey(sotrudnik => sotrudnik.ID);
2025-03-05 09:12:58 +00:00
2025-03-07 06:51:43 +00:00
mb.Entity<historyDao>().ToTable("history", "Demo_Blago").HasKey(history => history.id);
2025-03-05 09:12:58 +00:00
2025-02-11 10:23:14 +00:00
}
}