presence/data/RemoteData/RemoteDataBaseContext.cs

30 lines
1016 B
C#
Raw Normal View History

2024-11-08 08:08:54 +00:00
using Data.RemoteData.DAO;
using Microsoft.EntityFrameworkCore;
namespace data.RemoteData
{
public class RemoteDataBaseContext: DbContext
{
internal DbSet<GroupDao> Group { get; set; }
internal DbSet<UserDao> User { get; set; }
2024-11-08 08:29:02 +00:00
internal DbSet<PresnceDao> Presence { get; set; }
2024-11-08 08:08:54 +00:00
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<UserDao>().HasKey(user => user.Guid);
2024-11-08 08:29:02 +00:00
modelBuilder.Entity<PresnceDao>().HasKey(presence => new {
2024-11-08 08:08:54 +00:00
presence.UserGuid,
2024-11-08 08:29:02 +00:00
presence.IsAttendensy,
2024-11-08 08:08:54 +00:00
presence.Date,
presence.LessonNumber,
});
}
}
}