35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
using Demo.Data.RemoteData.RemoteDataBase.DAO;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Data.RemoteData.RemoteDataBase.DAO
|
|
{
|
|
|
|
public class RemoteDatabaseContext: DbContext {
|
|
|
|
public DbSet<GroupDao> Groups { get; set; }
|
|
public DbSet<UserDao> Users { get; set; }
|
|
public DbSet<PresenceDao> PresenceDaos { get; set; }
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
optionsBuilder.UseNpgsql("Host=localhost;" +
|
|
"Port=5432;" +
|
|
"Username=postgres;" +
|
|
"Password=1234;" +
|
|
"Database=postgres");
|
|
}
|
|
|
|
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.Guid);
|
|
modelBuilder.Entity<UserDao>().Property(user => user.Guid).ValueGeneratedOnAdd();
|
|
modelBuilder.Entity<PresenceDao>().HasKey(presence => new {
|
|
presence.UserGuid,
|
|
presence.Date,
|
|
presence.IsAttedance,
|
|
presence.LessonNumber
|
|
});
|
|
}
|
|
}
|
|
} |