Demka_kur/Hardik/Conect/Conector.cs

35 lines
1.2 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-03-05 09:12:58 +00:00
// options => options.EnableRetryOnFailure());
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)
{
mb.Entity<KlientDao>().HasKey(klient => klient.Code);
mb.Entity<KlientDao>().Property(klient => klient.Code).ValueGeneratedOnAdd();
2025-03-05 09:12:58 +00:00
2025-02-11 10:23:14 +00:00
mb.Entity<ordersDao>().HasKey(orders => orders.ID);
mb.Entity<ordersDao>().Property(orders => orders.ID).ValueGeneratedOnAdd();
2025-03-05 09:12:58 +00:00
2025-02-11 10:23:14 +00:00
mb.Entity<uslugiDao>().HasKey(uslugi => uslugi.ID);
2025-03-05 09:12:58 +00:00
2025-02-11 10:23:14 +00:00
mb.Entity<SotrudnikDao>().HasKey(sotrudnik => sotrudnik.ID);
2025-03-05 09:12:58 +00:00
2025-02-11 10:23:14 +00:00
mb.Entity<historyDao>().HasKey(history => history.id);
2025-03-05 09:12:58 +00:00
2025-02-11 10:23:14 +00:00
}
}