_43pBezaevaContext.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace Connect_with_base.Models;
  5. public partial class _43pBezaevaContext : DbContext
  6. {
  7. public _43pBezaevaContext()
  8. {
  9. }
  10. public _43pBezaevaContext(DbContextOptions<_43pBezaevaContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<Course> Courses { get; set; }
  15. public virtual DbSet<Discipline> Disciplines { get; set; }
  16. public virtual DbSet<Gender> Genders { get; set; }
  17. public virtual DbSet<Teacher> Teachers { get; set; }
  18. public virtual DbSet<TeacherCourse> TeacherCourses { get; set; }
  19. public virtual DbSet<TeacherDiscipline> TeacherDisciplines { 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.local;Port=5432;Database=43P_Bezaeva;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("courses_pkey");
  28. entity.ToTable("courses");
  29. entity.Property(e => e.Id).HasColumnName("id");
  30. entity.Property(e => e.Name)
  31. .HasMaxLength(100)
  32. .HasColumnName("name");
  33. entity.Property(e => e.Time)
  34. .HasMaxLength(50)
  35. .HasColumnName("time");
  36. });
  37. modelBuilder.Entity<Discipline>(entity =>
  38. {
  39. entity.HasKey(e => e.Id).HasName("disciplines_pkey");
  40. entity.ToTable("disciplines");
  41. entity.Property(e => e.Id).HasColumnName("id");
  42. entity.Property(e => e.Name)
  43. .HasMaxLength(100)
  44. .HasColumnName("name");
  45. });
  46. modelBuilder.Entity<Gender>(entity =>
  47. {
  48. entity.HasKey(e => e.Id).HasName("genders_pkey");
  49. entity.ToTable("genders");
  50. entity.Property(e => e.Id).HasColumnName("id");
  51. entity.Property(e => e.GenderName)
  52. .HasMaxLength(10)
  53. .HasColumnName("gender_name");
  54. });
  55. modelBuilder.Entity<Teacher>(entity =>
  56. {
  57. entity.HasKey(e => e.Id).HasName("teachers_pkey");
  58. entity.ToTable("teachers");
  59. entity.HasIndex(e => e.Email, "teachers_email_key").IsUnique();
  60. entity.Property(e => e.Id).HasColumnName("id");
  61. entity.Property(e => e.DateOfBirth)
  62. .HasColumnType("timestamp without time zone")
  63. .HasColumnName("date_of_birth");
  64. entity.Property(e => e.Email)
  65. .HasMaxLength(100)
  66. .HasColumnName("email");
  67. entity.Property(e => e.Experience).HasColumnName("experience");
  68. entity.Property(e => e.FirstName)
  69. .HasMaxLength(50)
  70. .HasColumnName("first_name");
  71. entity.Property(e => e.GenderId).HasColumnName("gender_id");
  72. entity.Property(e => e.LastName)
  73. .HasMaxLength(50)
  74. .HasColumnName("last_name");
  75. entity.Property(e => e.PatronymicName)
  76. .HasMaxLength(50)
  77. .HasColumnName("patronymic_name");
  78. entity.Property(e => e.Phone)
  79. .HasMaxLength(25)
  80. .HasColumnName("phone");
  81. entity.HasOne(d => d.Gender).WithMany(p => p.Teachers)
  82. .HasForeignKey(d => d.GenderId)
  83. .HasConstraintName("fk_gender");
  84. });
  85. modelBuilder.Entity<TeacherCourse>(entity =>
  86. {
  87. entity.HasKey(e => e.Id).HasName("teacher_course_pkey");
  88. entity.ToTable("teacher_course");
  89. entity.Property(e => e.Id).HasColumnName("id");
  90. entity.Property(e => e.CourseId).HasColumnName("course_id");
  91. entity.Property(e => e.TeacherId).HasColumnName("teacher_id");
  92. entity.HasOne(d => d.Course).WithMany(p => p.TeacherCourses)
  93. .HasForeignKey(d => d.CourseId)
  94. .HasConstraintName("fk_course");
  95. entity.HasOne(d => d.Teacher).WithMany(p => p.TeacherCourses)
  96. .HasForeignKey(d => d.TeacherId)
  97. .HasConstraintName("fk_teacher");
  98. });
  99. modelBuilder.Entity<TeacherDiscipline>(entity =>
  100. {
  101. entity.HasKey(e => e.Id).HasName("teacher_disciplines_pkey");
  102. entity.ToTable("teacher_disciplines");
  103. entity.Property(e => e.Id).HasColumnName("id");
  104. entity.Property(e => e.DisciplineId).HasColumnName("discipline_id");
  105. entity.Property(e => e.TeacherId).HasColumnName("teacher_id");
  106. entity.HasOne(d => d.Discipline).WithMany(p => p.TeacherDisciplines)
  107. .HasForeignKey(d => d.DisciplineId)
  108. .HasConstraintName("fk_disciplines");
  109. entity.HasOne(d => d.Teacher).WithMany(p => p.TeacherDisciplines)
  110. .HasForeignKey(d => d.TeacherId)
  111. .HasConstraintName("fk_teacher");
  112. });
  113. OnModelCreatingPartial(modelBuilder);
  114. }
  115. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  116. }