_43pToropovaContext.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace AvaloniaTeachersDB.Models;
  5. public partial class _43pToropovaContext : DbContext
  6. {
  7. public _43pToropovaContext()
  8. {
  9. }
  10. public _43pToropovaContext(DbContextOptions<_43pToropovaContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<Course> Courses { get; set; }
  15. public virtual DbSet<Gender> Genders { get; set; }
  16. public virtual DbSet<SchoolSubject> SchoolSubjects { get; set; }
  17. public virtual DbSet<Teacher> Teachers { get; set; }
  18. public virtual DbSet<TeacherCourse> TeacherCourses { get; set; }
  19. public virtual DbSet<TeachersSubject> TeachersSubjects { get; set; }
  20. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  21. #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.
  22. => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.local;Port=5432;Database=43P_Toropova;Username=43P;Password=444444");
  23. protected override void OnModelCreating(ModelBuilder modelBuilder)
  24. {
  25. modelBuilder.Entity<Course>(entity =>
  26. {
  27. entity.HasKey(e => e.IdCourses).HasName("courses_pk");
  28. entity.ToTable("courses");
  29. entity.Property(e => e.IdCourses)
  30. .UseIdentityAlwaysColumn()
  31. .HasColumnName("id_courses");
  32. entity.Property(e => e.NameCourses)
  33. .HasColumnType("character varying")
  34. .HasColumnName("name_courses");
  35. });
  36. modelBuilder.Entity<Gender>(entity =>
  37. {
  38. entity.HasKey(e => e.IdGender).HasName("genders_pk");
  39. entity.ToTable("genders");
  40. entity.Property(e => e.IdGender)
  41. .UseIdentityAlwaysColumn()
  42. .HasColumnName("id_gender");
  43. entity.Property(e => e.NameGender)
  44. .HasColumnType("character varying")
  45. .HasColumnName("name_gender");
  46. });
  47. modelBuilder.Entity<SchoolSubject>(entity =>
  48. {
  49. entity.HasKey(e => e.IdSubjects).HasName("school_subjects_pk");
  50. entity.ToTable("school_subjects");
  51. entity.Property(e => e.IdSubjects)
  52. .UseIdentityAlwaysColumn()
  53. .HasColumnName("id_subjects");
  54. entity.Property(e => e.NameSubjects)
  55. .HasColumnType("character varying")
  56. .HasColumnName("name__subjects");
  57. });
  58. modelBuilder.Entity<Teacher>(entity =>
  59. {
  60. entity.HasKey(e => e.IdTeachers).HasName("teachers_pk");
  61. entity.ToTable("teachers");
  62. entity.Property(e => e.IdTeachers)
  63. .UseIdentityAlwaysColumn()
  64. .HasColumnName("id_teachers");
  65. entity.Property(e => e.BirthdayTeacher).HasColumnName("birthday_teacher");
  66. entity.Property(e => e.ExperienceTeacher).HasColumnName("experience_teacher");
  67. entity.Property(e => e.IdGender).HasColumnName("id_gender");
  68. entity.Property(e => e.Mail)
  69. .HasColumnType("character varying")
  70. .HasColumnName("mail");
  71. entity.Property(e => e.NameTeacher)
  72. .HasColumnType("character varying")
  73. .HasColumnName("name_teacher");
  74. entity.Property(e => e.PatronymicTeacher)
  75. .HasColumnType("character varying")
  76. .HasColumnName("patronymic_teacher");
  77. entity.Property(e => e.Phone)
  78. .HasColumnType("character varying")
  79. .HasColumnName("phone");
  80. entity.Property(e => e.SurnameTeacher)
  81. .HasColumnType("character varying")
  82. .HasColumnName("surname_teacher");
  83. entity.HasOne(d => d.IdGenderNavigation).WithMany(p => p.Teachers)
  84. .HasForeignKey(d => d.IdGender)
  85. .HasConstraintName("teachers_fk");
  86. });
  87. modelBuilder.Entity<TeacherCourse>(entity =>
  88. {
  89. entity.HasKey(e => e.IdTeacherCourse).HasName("teacher_courses_pk");
  90. entity.ToTable("teacher_courses");
  91. entity.Property(e => e.IdTeacherCourse)
  92. .UseIdentityAlwaysColumn()
  93. .HasColumnName("id_teacher_course");
  94. entity.Property(e => e.IdCourse).HasColumnName("id_course");
  95. entity.Property(e => e.IdTeacher).HasColumnName("id_teacher");
  96. entity.Property(e => e.TimeHours).HasColumnName("time_hours");
  97. entity.HasOne(d => d.IdCourseNavigation).WithMany(p => p.TeacherCourses)
  98. .HasForeignKey(d => d.IdCourse)
  99. .HasConstraintName("teacher_courses_fk");
  100. entity.HasOne(d => d.IdTeacherNavigation).WithMany(p => p.TeacherCourses)
  101. .HasForeignKey(d => d.IdTeacher)
  102. .HasConstraintName("teacher_courses_fk_1");
  103. });
  104. modelBuilder.Entity<TeachersSubject>(entity =>
  105. {
  106. entity.HasKey(e => e.IdTeacherSubjects).HasName("teachers_subjects_pk");
  107. entity.ToTable("teachers_subjects");
  108. entity.Property(e => e.IdTeacherSubjects)
  109. .UseIdentityAlwaysColumn()
  110. .HasColumnName("id_teacher_subjects");
  111. entity.Property(e => e.IdSubjects).HasColumnName("id_subjects");
  112. entity.Property(e => e.IdTeacher).HasColumnName("id_teacher");
  113. entity.HasOne(d => d.IdSubjectsNavigation).WithMany(p => p.TeachersSubjects)
  114. .HasForeignKey(d => d.IdSubjects)
  115. .HasConstraintName("teachers_subjects_fk_1");
  116. entity.HasOne(d => d.IdTeacherNavigation).WithMany(p => p.TeachersSubjects)
  117. .HasForeignKey(d => d.IdTeacher)
  118. .HasConstraintName("teachers_subjects_fk");
  119. });
  120. OnModelCreatingPartial(modelBuilder);
  121. }
  122. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  123. }