_43pKotkovaContext.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace N11_1.Models;
  5. public partial class _43pKotkovaContext : DbContext
  6. {
  7. public _43pKotkovaContext()
  8. {
  9. }
  10. public _43pKotkovaContext(DbContextOptions<_43pKotkovaContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<TbCourse> TbCourses { get; set; }
  15. public virtual DbSet<TbGender> TbGenders { get; set; }
  16. public virtual DbSet<TbLesson> TbLessons { get; set; }
  17. public virtual DbSet<TbTeacher> TbTeachers { get; set; }
  18. public virtual DbSet<TbTeachersCourse> TbTeachersCourses { get; set; }
  19. public virtual DbSet<TbTeachersLesson> TbTeachersLessons { 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_Kotkova;Username=43P;Password=444444");
  23. protected override void OnModelCreating(ModelBuilder modelBuilder)
  24. {
  25. modelBuilder.Entity<TbCourse>(entity =>
  26. {
  27. entity.HasKey(e => e.Id).HasName("tb_courses_pk");
  28. entity.ToTable("tb_courses");
  29. entity.Property(e => e.Id)
  30. .UseIdentityAlwaysColumn()
  31. .HasColumnName("id");
  32. entity.Property(e => e.Name)
  33. .HasColumnType("character varying")
  34. .HasColumnName("name");
  35. });
  36. modelBuilder.Entity<TbGender>(entity =>
  37. {
  38. entity.HasKey(e => e.Id).HasName("tb_gender_pk");
  39. entity.ToTable("tb_gender");
  40. entity.Property(e => e.Id)
  41. .UseIdentityAlwaysColumn()
  42. .HasColumnName("id");
  43. entity.Property(e => e.Name)
  44. .HasColumnType("character varying")
  45. .HasColumnName("name");
  46. });
  47. modelBuilder.Entity<TbLesson>(entity =>
  48. {
  49. entity.HasKey(e => e.Id).HasName("tb_lesson_pk");
  50. entity.ToTable("tb_lesson");
  51. entity.Property(e => e.Id)
  52. .UseIdentityAlwaysColumn()
  53. .HasColumnName("id");
  54. entity.Property(e => e.Name)
  55. .HasColumnType("character varying")
  56. .HasColumnName("name");
  57. });
  58. modelBuilder.Entity<TbTeacher>(entity =>
  59. {
  60. entity.HasKey(e => e.Id).HasName("tb_teachers_pk");
  61. entity.ToTable("tb_teachers");
  62. entity.Property(e => e.Id)
  63. .UseIdentityAlwaysColumn()
  64. .HasColumnName("id");
  65. entity.Property(e => e.DateOf)
  66. .HasColumnType("timestamp without time zone")
  67. .HasColumnName("date_of");
  68. entity.Property(e => e.Email)
  69. .HasColumnType("character varying")
  70. .HasColumnName("email");
  71. entity.Property(e => e.FirstName)
  72. .HasColumnType("character varying")
  73. .HasColumnName("first_name");
  74. entity.Property(e => e.IdGender).HasColumnName("id_gender");
  75. entity.Property(e => e.LastName)
  76. .HasColumnType("character varying")
  77. .HasColumnName("last_name");
  78. entity.Property(e => e.Patronymic)
  79. .HasColumnType("character varying")
  80. .HasColumnName("patronymic");
  81. entity.Property(e => e.Phone)
  82. .HasColumnType("character varying")
  83. .HasColumnName("phone");
  84. entity.Property(e => e.WorkExperience).HasColumnName("work_experience");
  85. entity.HasOne(d => d.IdGenderNavigation).WithMany(p => p.TbTeachers)
  86. .HasForeignKey(d => d.IdGender)
  87. .OnDelete(DeleteBehavior.ClientSetNull)
  88. .HasConstraintName("tb_teachers_fk");
  89. });
  90. modelBuilder.Entity<TbTeachersCourse>(entity =>
  91. {
  92. entity.HasKey(e => e.Id).HasName("tb_teachers_courses_pk");
  93. entity.ToTable("tb_teachers_courses");
  94. entity.Property(e => e.Id)
  95. .UseIdentityAlwaysColumn()
  96. .HasColumnName("id");
  97. entity.Property(e => e.Hours).HasColumnName("hours");
  98. entity.Property(e => e.IdCourses).HasColumnName("id_courses");
  99. entity.Property(e => e.IdTeacher).HasColumnName("id_teacher");
  100. entity.HasOne(d => d.IdCoursesNavigation).WithMany(p => p.TbTeachersCourses)
  101. .HasForeignKey(d => d.IdCourses)
  102. .OnDelete(DeleteBehavior.ClientSetNull)
  103. .HasConstraintName("tb_teachers_courses_fk_1");
  104. entity.HasOne(d => d.IdTeacherNavigation).WithMany(p => p.TbTeachersCourses)
  105. .HasForeignKey(d => d.IdTeacher)
  106. .OnDelete(DeleteBehavior.ClientSetNull)
  107. .HasConstraintName("tb_teachers_courses_fk");
  108. });
  109. modelBuilder.Entity<TbTeachersLesson>(entity =>
  110. {
  111. entity.HasKey(e => e.Id).HasName("tb_teachers_lessons_pk");
  112. entity.ToTable("tb_teachers_lessons");
  113. entity.Property(e => e.Id)
  114. .UseIdentityAlwaysColumn()
  115. .HasColumnName("id");
  116. entity.Property(e => e.IdLesson).HasColumnName("id_lesson");
  117. entity.Property(e => e.IdTeacher).HasColumnName("id_teacher");
  118. entity.HasOne(d => d.IdLessonNavigation).WithMany(p => p.TbTeachersLessons)
  119. .HasForeignKey(d => d.IdLesson)
  120. .OnDelete(DeleteBehavior.ClientSetNull)
  121. .HasConstraintName("tb_teachers_lessons_fk_1");
  122. entity.HasOne(d => d.IdTeacherNavigation).WithMany(p => p.TbTeachersLessons)
  123. .HasForeignKey(d => d.IdTeacher)
  124. .OnDelete(DeleteBehavior.ClientSetNull)
  125. .HasConstraintName("tb_teachers_lessons_fk");
  126. });
  127. OnModelCreatingPartial(modelBuilder);
  128. }
  129. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  130. }