2024-12-12 07:21:45 +00:00
|
|
|
|
using Data.DAO;
|
2024-11-16 12:34:29 +00:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace data
|
|
|
|
|
{
|
2024-11-16 21:45:57 +00:00
|
|
|
|
public class RemoteDatabaseContext: DbContext
|
2024-11-16 12:34:29 +00:00
|
|
|
|
{
|
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
|
|
|
{
|
|
|
|
|
optionsBuilder.UseNpgsql("Host=localhost;port=5432;Password=admin;Username=postgres;Database=semesterWork");
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-12 07:21:45 +00:00
|
|
|
|
//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
|
|
|
//{
|
|
|
|
|
// optionsBuilder.UseNpgsql("Host=45.67.56.214; Port=5454; Username=user3; Password=VOTfZ8PQ; Database=user3");
|
|
|
|
|
//}
|
2024-11-16 12:34:29 +00:00
|
|
|
|
|
2024-12-12 07:21:45 +00:00
|
|
|
|
|
|
|
|
|
public DbSet<Group> Groups { get; set; }
|
|
|
|
|
public DbSet<Student> Students { get; set; }
|
|
|
|
|
public DbSet<Attendance> Attendances { get; set; }
|
|
|
|
|
public DbSet<GroupSubject> GroupSubjects { get; set; }
|
|
|
|
|
public DbSet<Semester> Semesters { get; set; }
|
|
|
|
|
public DbSet<Subject> Subjects { get; set; }
|
|
|
|
|
public DbSet<Visit> Visits { get; set; }
|
2024-11-16 12:34:29 +00:00
|
|
|
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
2024-12-12 07:21:45 +00:00
|
|
|
|
modelBuilder.Entity<Student>().HasKey(it => it.StudentId);
|
|
|
|
|
modelBuilder.Entity<Group>().HasKey(it => it.GroupId);
|
|
|
|
|
modelBuilder.Entity<GroupSubject>().HasKey(it => it.GroupSubjectId);
|
|
|
|
|
modelBuilder.Entity<Semester>().HasKey(it => it.SemesterId);
|
|
|
|
|
modelBuilder.Entity<Visit>().HasKey(it => it.VisitId);
|
|
|
|
|
modelBuilder.Entity<Subject>().HasKey(it => it.SubjectId);
|
|
|
|
|
modelBuilder.Entity<Attendance>().HasKey(it => it.AttendanceId);
|
2024-11-16 12:34:29 +00:00
|
|
|
|
|
2024-12-12 07:21:45 +00:00
|
|
|
|
modelBuilder.Entity<Student>().Property(it => it.StudentId).ValueGeneratedOnAdd();
|
|
|
|
|
modelBuilder.Entity<Group>().Property(it => it.GroupId).ValueGeneratedOnAdd();
|
|
|
|
|
modelBuilder.Entity<GroupSubject>().Property(it => it.GroupSubjectId).ValueGeneratedOnAdd();
|
|
|
|
|
modelBuilder.Entity<Semester>().Property(it => it.SemesterId).ValueGeneratedOnAdd();
|
|
|
|
|
modelBuilder.Entity<Visit>().Property(it => it.VisitId).ValueGeneratedOnAdd();
|
|
|
|
|
modelBuilder.Entity<Subject>().Property(it => it.SubjectId).ValueGeneratedOnAdd();
|
|
|
|
|
modelBuilder.Entity<Attendance>().Property(it => it.AttendanceId).ValueGeneratedOnAdd();
|
2024-11-16 12:34:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|