presence/RemaDateBase/RemoutDateBase.cs

32 lines
1.1 KiB
C#
Raw Normal View History

2024-11-14 10:09:14 +00:00
using Microsoft.EntityFrameworkCore;
using Zurnal.RemaDateBase.DateDao;
public class RemoteDateBaseContext : DbContext
{
public DbSet<GroupDao> Group { get; set; }
public DbSet<UserDao> User { get; set; }
public DbSet<PresnceDao> Presence { get; set; }
public object Groups { get; internal set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql("Host=45.67.56.214;Port=5421;Username=user16;Password=dZ28IVE5;Database=user16");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<GroupDao>().HasKey(group => group.Id);
modelBuilder.Entity<GroupDao>().Property(group => group.Id).ValueGeneratedOnAdd();
modelBuilder.Entity<UserDao>().HasKey(user => user.UserGuid);
modelBuilder.Entity<UserDao>().Property(user => user.UserGuid).ValueGeneratedOnAdd();
modelBuilder.Entity<PresnceDao>().HasKey(presence => new
{
presence.UserGuid,
presence.Date,
presence.IsAttendensy,
presence.LessonNumber
});
}
}