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