35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Posechaemost.Data.RemoteData.RemoteDataBase.DAO;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Posechaemost.Data.RemoteData.RemoteDataBase
|
|
{
|
|
public class RemoteDataBaseContext: DbContext
|
|
{
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder){
|
|
optionsBuilder.UseNpgsql();
|
|
}
|
|
|
|
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.User,
|
|
presence.Date,
|
|
presence.IsAttendence,
|
|
presence.ClassNumber
|
|
});
|
|
}
|
|
|
|
|
|
public DbSet<GroupDao> groups{ get; set; }
|
|
public DbSet<UserDao> users{ get; set; }
|
|
public DbSet<PresenceDao> presences{ get; set; }
|
|
}
|
|
} |