Raspisanie/Zurnal/RemaDateBase/RemoutDateBase.cs
2024-10-24 14:43:25 +03:00

34 lines
1.0 KiB
C#

using System;
using Microsoft.EntityFrameworkCore;
public class RemoteDateBaseContext: DbContext
{
public Class()
{
public DbSet<GroupDao> Group { get; set; }
public DbSet<UserDao> User { get; set; }
public DbSet<PresnceDao> Presnce { get; set; }
protected override void Conector(DbContextOptionsBuilder optionsBulder)
{
optionsBulder.UseNpgsql("Host=Localhost;" + "Port=5432;" + "Username=postgres;" + "Password=123" + "DateBase=postgres");
}
protected override void OnMode(ModelBuilder modelBulder)
{
modelBulder.Entity<GroupDao>().HasKey(Group => Group.Id);
modelBulder.Entity<GroupDao>().Property(Group => Group.Id).ValueGeneratedOnAdd();
modelBulder.Entity<UserDao>().HasKey(User => User.Guid);
modelBulder.Entity<UserDao>().Property(User => User.Guid).ValueGeneratedOnAdd();
modelBulder.Entity<PresnceDao>().HasKey(Presnce => new
{
Presnce.UserGuid,
Presnce.Date,
Presnce.IsAttendensy,
Presnce.LessonNumber
});
}
}
}