123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- using System;
- using System.Collections.Generic;
- using Microsoft.EntityFrameworkCore;
- namespace Prak12;
- public partial class AvaloniaPrakt12DbContext : DbContext
- {
- public AvaloniaPrakt12DbContext()
- {
- }
- public AvaloniaPrakt12DbContext(DbContextOptions<AvaloniaPrakt12DbContext> options)
- : base(options)
- {
- }
- public virtual DbSet<Course> Courses { get; set; }
- public virtual DbSet<Gender> Genders { get; set; }
- public virtual DbSet<Subject> Subjects { get; set; }
- public virtual DbSet<Teacher> Teachers { get; set; }
- public virtual DbSet<TeachersCourse> TeachersCourses { get; set; }
- public virtual DbSet<TeachersSubject> TeachersSubjects { get; set; }
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- #warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
- => optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=AvaloniaPrakt12DB;Username=postgres;Password=k08760365");
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.Entity<Course>(entity =>
- {
- entity.HasKey(e => e.IdCourse).HasName("courses_pk");
- entity.ToTable("courses");
- entity.Property(e => e.IdCourse)
- .UseIdentityAlwaysColumn()
- .HasColumnName("id_course");
- entity.Property(e => e.CourseHoursNumber).HasColumnName("course_hours_number");
- entity.Property(e => e.CourseName)
- .HasColumnType("character varying")
- .HasColumnName("course_name");
- });
- modelBuilder.Entity<Gender>(entity =>
- {
- entity.HasKey(e => e.IdGender).HasName("gender_pk");
- entity.ToTable("genders");
- entity.Property(e => e.IdGender)
- .UseIdentityAlwaysColumn()
- .HasColumnName("id_gender");
- entity.Property(e => e.GenderName)
- .HasColumnType("character varying")
- .HasColumnName("gender_name");
- });
- modelBuilder.Entity<Subject>(entity =>
- {
- entity.HasKey(e => e.IdSubjects).HasName("items_pk");
- entity.ToTable("subjects");
- entity.Property(e => e.IdSubjects)
- .UseIdentityAlwaysColumn()
- .HasColumnName("id_subjects");
- entity.Property(e => e.SubjectName)
- .HasColumnType("character varying")
- .HasColumnName("subject_name");
- });
- modelBuilder.Entity<Teacher>(entity =>
- {
- entity.HasKey(e => e.IdTeacher).HasName("teachers_pk");
- entity.ToTable("teachers");
- entity.Property(e => e.IdTeacher)
- .UseIdentityAlwaysColumn()
- .HasColumnName("id_teacher");
- entity.Property(e => e.IdGender).HasColumnName("id_gender");
- entity.Property(e => e.TeacherBirthdate).HasColumnName("teacher_birthdate");
- entity.Property(e => e.TeacherEmail)
- .HasColumnType("character varying")
- .HasColumnName("teacher_email");
- entity.Property(e => e.TeacherName)
- .HasColumnType("character varying")
- .HasColumnName("teacher_name");
- entity.Property(e => e.TeacherPatronymic)
- .HasColumnType("character varying")
- .HasColumnName("teacher_patronymic");
- entity.Property(e => e.TeacherPhoneNumber)
- .HasColumnType("character varying")
- .HasColumnName("teacher_phone_number");
- entity.Property(e => e.TeacherSurname)
- .HasColumnType("character varying")
- .HasColumnName("teacher_surname");
- entity.Property(e => e.TeacherWorkTime).HasColumnName("teacher_work_time");
- entity.HasOne(d => d.IdGenderNavigation).WithMany(p => p.Teachers)
- .HasForeignKey(d => d.IdGender)
- .HasConstraintName("teachers_fk");
- });
- modelBuilder.Entity<TeachersCourse>(entity =>
- {
- entity.HasKey(e => e.IdRecord).HasName("teachers_courses_pk");
- entity.ToTable("teachers_courses");
- entity.Property(e => e.IdRecord)
- .UseIdentityAlwaysColumn()
- .HasColumnName("id_record");
- entity.Property(e => e.IdCourse).HasColumnName("id_course");
- entity.Property(e => e.IdTeacher).HasColumnName("id_teacher");
- entity.HasOne(d => d.IdCourseNavigation).WithMany(p => p.TeachersCourses)
- .HasForeignKey(d => d.IdCourse)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("teachers_courses_fk_1");
- entity.HasOne(d => d.IdTeacherNavigation).WithMany(p => p.TeachersCourses)
- .HasForeignKey(d => d.IdTeacher)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("teachers_courses_fk");
- });
- modelBuilder.Entity<TeachersSubject>(entity =>
- {
- entity.HasKey(e => e.IdRecord).HasName("teachers_subjects_pk");
- entity.ToTable("teachers_subjects");
- entity.Property(e => e.IdRecord)
- .UseIdentityAlwaysColumn()
- .HasColumnName("id_record");
- entity.Property(e => e.IdSubject).HasColumnName("id_subject");
- entity.Property(e => e.IdTeacher).HasColumnName("id_teacher");
- entity.HasOne(d => d.IdSubjectNavigation).WithMany(p => p.TeachersSubjects)
- .HasForeignKey(d => d.IdSubject)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("teachers_subjects_fk");
- entity.HasOne(d => d.IdTeacherNavigation).WithMany(p => p.TeachersSubjects)
- .HasForeignKey(d => d.IdTeacher)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("teachers_subjects_fk_1");
- });
- OnModelCreatingPartial(modelBuilder);
- }
- partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
- }
|