demp_with_asp/data/RemoteData/RemoteDataBaseContext.cs

30 lines
1013 B
C#
Raw Permalink Normal View History

2024-11-05 21:46:20 +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; }
internal DbSet<PresenceDao> Presence { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql("Host=localhost;Username=postgres;Port=5432;Database=Presence;Password=123");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<GroupDao>().HasKey(group => group.Id);
modelBuilder.Entity<UserDao>().HasKey(user => user.Guid);
modelBuilder.Entity<PresenceDao>().HasKey(presence => new {
presence.UserGuid,
presence.IsAttedance,
presence.Date,
presence.LessonNumber,
});
}
}
}