37 lines
1.4 KiB
C#
37 lines
1.4 KiB
C#
|
using presence.Data.RemoteData.RemoteDatabase.DAO;
|
|||
|
using Microsoft.EntityFrameworkCore;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace presence.Data.RemoteData.RemoteDatabase
|
|||
|
{
|
|||
|
public class RemoteDatabaseContext: DbContext
|
|||
|
{
|
|||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|||
|
{
|
|||
|
optionsBuilder.UseNpgsql("Host = 45.67.56.214; Port = 5454; Username = user3; Database = user3; Password = VOTfZ8PQ");
|
|||
|
}
|
|||
|
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.UserID);
|
|||
|
modelBuilder.Entity<UserDao>().Property(user => user.UserID).ValueGeneratedOnAdd();
|
|||
|
modelBuilder.Entity<PresenceDao>().HasKey(presence => new
|
|||
|
{
|
|||
|
presence.UserDaoUserId,
|
|||
|
presence.Date,
|
|||
|
presence.IsAttedance,
|
|||
|
presence.LessonNumber
|
|||
|
});
|
|||
|
}
|
|||
|
public DbSet<GroupDao> Groups { get; set; }
|
|||
|
public DbSet<UserDao> Users { get; set; }
|
|||
|
public DbSet<PresenceDao> PresencesDaos { get; set; }
|
|||
|
}
|
|||
|
}
|
|||
|
|