_43pTryaninaContext.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace Teachers.Models;
  5. public partial class _43pTryaninaContext : DbContext
  6. {
  7. public _43pTryaninaContext()
  8. {
  9. }
  10. public _43pTryaninaContext(DbContextOptions<_43pTryaninaContext> 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<Subject> Subjects { get; set; }
  17. public virtual DbSet<SubjectsTaught> SubjectsTaughts { get; set; }
  18. public virtual DbSet<Teacher> Teachers { get; set; }
  19. public virtual DbSet<TeacherCourse> TeacherCourses { 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 https://go.microsoft.com/fwlink/?LinkId=723263.
  22. => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.ru;Port=5442;Database=43P_Tryanina;Username=43P;Password=444444");
  23. protected override void OnModelCreating(ModelBuilder modelBuilder)
  24. {
  25. modelBuilder.Entity<Course>(entity =>
  26. {
  27. entity.HasKey(e => e.Id).HasName("subjects_pk_1");
  28. entity.ToTable("courses");
  29. entity.Property(e => e.Id).HasColumnName("id");
  30. entity.Property(e => e.Duration).HasColumnName("duration");
  31. entity.Property(e => e.Name)
  32. .HasMaxLength(100)
  33. .HasColumnName("name");
  34. });
  35. modelBuilder.Entity<Gender>(entity =>
  36. {
  37. entity.HasKey(e => e.Id).HasName("genders_pk");
  38. entity.ToTable("genders");
  39. entity.Property(e => e.Id).HasColumnName("id");
  40. entity.Property(e => e.Gender1)
  41. .HasMaxLength(10)
  42. .HasColumnName("gender");
  43. });
  44. modelBuilder.Entity<Subject>(entity =>
  45. {
  46. entity.HasKey(e => e.Id).HasName("subjects_pk");
  47. entity.ToTable("subjects");
  48. entity.Property(e => e.Id).HasColumnName("id");
  49. entity.Property(e => e.Name)
  50. .HasMaxLength(50)
  51. .HasColumnName("name");
  52. });
  53. modelBuilder.Entity<SubjectsTaught>(entity =>
  54. {
  55. entity.HasKey(e => e.IdSt).HasName("subjects_taught_pk");
  56. entity.ToTable("subjects_taught");
  57. entity.Property(e => e.IdSt).HasColumnName("id_st");
  58. entity.Property(e => e.IdSubject)
  59. .ValueGeneratedOnAdd()
  60. .HasColumnName("id_subject");
  61. entity.Property(e => e.IdTeacher)
  62. .ValueGeneratedOnAdd()
  63. .HasColumnName("id_teacher");
  64. entity.HasOne(d => d.IdSubjectNavigation).WithMany(p => p.SubjectsTaughts)
  65. .HasForeignKey(d => d.IdSubject)
  66. .HasConstraintName("subjects_taught_subjects_fk");
  67. entity.HasOne(d => d.IdTeacherNavigation).WithMany(p => p.SubjectsTaughts)
  68. .HasForeignKey(d => d.IdTeacher)
  69. .HasConstraintName("subjects_taught_teachers_fk");
  70. });
  71. modelBuilder.Entity<Teacher>(entity =>
  72. {
  73. entity.HasKey(e => e.Id).HasName("teachers_pk");
  74. entity.ToTable("teachers");
  75. entity.Property(e => e.Id).HasColumnName("id");
  76. entity.Property(e => e.Birthday)
  77. .HasColumnType("timestamp without time zone")
  78. .HasColumnName("birthday");
  79. entity.Property(e => e.Email)
  80. .HasMaxLength(100)
  81. .HasColumnName("email");
  82. entity.Property(e => e.Experience).HasColumnName("experience");
  83. entity.Property(e => e.Gender)
  84. .HasDefaultValue(1)
  85. .HasColumnName("gender");
  86. entity.Property(e => e.Name)
  87. .HasMaxLength(20)
  88. .HasColumnName("name");
  89. entity.Property(e => e.Patronymic)
  90. .HasMaxLength(20)
  91. .HasColumnName("patronymic");
  92. entity.Property(e => e.Phone)
  93. .HasMaxLength(25)
  94. .HasColumnName("phone");
  95. entity.Property(e => e.Surname)
  96. .HasMaxLength(20)
  97. .HasColumnName("surname");
  98. entity.HasOne(d => d.GenderNavigation).WithMany(p => p.Teachers)
  99. .HasForeignKey(d => d.Gender)
  100. .HasConstraintName("teachers_genders_fk");
  101. });
  102. modelBuilder.Entity<TeacherCourse>(entity =>
  103. {
  104. entity.HasKey(e => e.IdTc).HasName("teacher_courses_pk");
  105. entity.ToTable("teacher_courses");
  106. entity.Property(e => e.IdTc).HasColumnName("id_tc");
  107. entity.Property(e => e.IdCourse)
  108. .ValueGeneratedOnAdd()
  109. .HasColumnName("id_course");
  110. entity.Property(e => e.IdTeacher)
  111. .ValueGeneratedOnAdd()
  112. .HasColumnName("id_teacher");
  113. entity.HasOne(d => d.IdCourseNavigation).WithMany(p => p.TeacherCourses)
  114. .HasForeignKey(d => d.IdCourse)
  115. .HasConstraintName("teacher_courses_courses_fk");
  116. entity.HasOne(d => d.IdTeacherNavigation).WithMany(p => p.TeacherCourses)
  117. .HasForeignKey(d => d.IdTeacher)
  118. .HasConstraintName("teacher_courses_teachers_fk");
  119. });
  120. OnModelCreatingPartial(modelBuilder);
  121. }
  122. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  123. }