using Data.DAO; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace data { public class RemoteDatabaseContext: DbContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseNpgsql("Host=localhost;port=5432;Password=admin;Username=postgres;Database=semesterWork"); } //protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) //{ // optionsBuilder.UseNpgsql("Host=45.67.56.214; Port=5454; Username=user3; Password=VOTfZ8PQ; Database=user3"); //} public DbSet Groups { get; set; } public DbSet Students { get; set; } public DbSet Attendances { get; set; } public DbSet GroupSubjects { get; set; } public DbSet Semesters { get; set; } public DbSet Subjects { get; set; } public DbSet Visits { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().HasKey(it => it.StudentId); modelBuilder.Entity().HasKey(it => it.GroupId); modelBuilder.Entity().HasKey(it => it.GroupSubjectId); modelBuilder.Entity().HasKey(it => it.SemesterId); modelBuilder.Entity().HasKey(it => it.VisitId); modelBuilder.Entity().HasKey(it => it.SubjectId); modelBuilder.Entity().HasKey(it => it.AttendanceId); modelBuilder.Entity().Property(it => it.StudentId).ValueGeneratedOnAdd(); modelBuilder.Entity().Property(it => it.GroupId).ValueGeneratedOnAdd(); modelBuilder.Entity().Property(it => it.GroupSubjectId).ValueGeneratedOnAdd(); modelBuilder.Entity().Property(it => it.SemesterId).ValueGeneratedOnAdd(); modelBuilder.Entity().Property(it => it.VisitId).ValueGeneratedOnAdd(); modelBuilder.Entity().Property(it => it.SubjectId).ValueGeneratedOnAdd(); modelBuilder.Entity().Property(it => it.AttendanceId).ValueGeneratedOnAdd(); } } }