PostgresContext.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace pr13.Models;
  5. public partial class PostgresContext : DbContext
  6. {
  7. public PostgresContext()
  8. {
  9. }
  10. public PostgresContext(DbContextOptions<PostgresContext> 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<Role> Roles { get; set; }
  17. public virtual DbSet<Teacher> Teachers { get; set; }
  18. public virtual DbSet<TeachersCourse> TeachersCourses { get; set; }
  19. public virtual DbSet<User> Users { 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=Smirnov2;Username=43P;Password=444444");
  23. protected override void OnModelCreating(ModelBuilder modelBuilder)
  24. {
  25. modelBuilder.HasPostgresExtension("pg_catalog", "adminpack");
  26. modelBuilder.Entity<Course>(entity =>
  27. {
  28. entity.HasKey(e => e.Idcurs).HasName("newtable_pk");
  29. entity.ToTable("courses");
  30. entity.Property(e => e.Idcurs)
  31. .UseIdentityAlwaysColumn()
  32. .HasColumnName("idcurs");
  33. entity.Property(e => e.Course1)
  34. .HasColumnType("character varying")
  35. .HasColumnName("curs");
  36. });
  37. modelBuilder.Entity<Gender>(entity =>
  38. {
  39. entity.HasKey(e => e.Id).HasName("genders_pk");
  40. entity.ToTable("gender");
  41. entity.Property(e => e.Id)
  42. .UseIdentityAlwaysColumn()
  43. .HasColumnName("idgender");
  44. entity.Property(e => e.Gender1)
  45. .HasColumnType("character varying")
  46. .HasColumnName("namegender");
  47. });
  48. modelBuilder.Entity<Role>(entity =>
  49. {
  50. entity.HasKey(e => e.IdRole).HasName("roles_pk");
  51. entity.ToTable("roles");
  52. entity.Property(e => e.IdRole)
  53. .UseIdentityAlwaysColumn()
  54. .HasColumnName("id_role");
  55. entity.Property(e => e.Role1)
  56. .HasColumnType("character varying")
  57. .HasColumnName("role");
  58. });
  59. modelBuilder.Entity<Teacher>(entity =>
  60. {
  61. entity.HasKey(e => e.IdTeacher).HasName("teachers_pk");
  62. entity.ToTable("teachers");
  63. entity.Property(e => e.IdTeacher)
  64. .ValueGeneratedOnAdd()
  65. .UseIdentityAlwaysColumn()
  66. .HasColumnName("idteacher");
  67. entity.Property(e => e.Birthdate)
  68. .HasColumnType("timestamp without time zone")
  69. .HasColumnName("dr");
  70. entity.Property(e => e.Email)
  71. .HasColumnType("character varying")
  72. .HasColumnName("mail");
  73. entity.Property(e => e.Expirience).HasColumnName("stash");
  74. entity.Property(e => e.IdGender).HasColumnName("idgender");
  75. entity.Property(e => e.Name)
  76. .HasColumnType("character varying")
  77. .HasColumnName("name");
  78. entity.Property(e => e.Patronymic)
  79. .HasColumnType("character varying")
  80. .HasColumnName("otchestvo");
  81. entity.Property(e => e.Phone)
  82. .HasColumnType("character varying")
  83. .HasColumnName("phone");
  84. entity.Property(e => e.Surname)
  85. .HasColumnType("character varying")
  86. .HasColumnName("familia");
  87. entity.HasOne(d => d.IdGenderNavigation).WithMany(p => p.Teachers)
  88. .HasForeignKey(d => d.IdGender)
  89. .HasConstraintName("teacher_fk");
  90. entity.HasOne(d => d.IdTeacherNavigation).WithOne(p => p.Teacher)
  91. .HasForeignKey<Teacher>(d => d.IdTeacher)
  92. .HasConstraintName("teacher_fk1");
  93. });
  94. modelBuilder.Entity<TeachersCourse>(entity =>
  95. {
  96. entity.HasKey(e => e.Id).HasName("teachers_courses_pk");
  97. entity.ToTable("teachers_courses");
  98. entity.Property(e => e.Id)
  99. .UseIdentityAlwaysColumn()
  100. .HasColumnName("id");
  101. entity.Property(e => e.Hours).HasColumnName("time");
  102. entity.Property(e => e.IdCourse).HasColumnName("idcurs");
  103. entity.Property(e => e.IdTeacher).HasColumnName("idteacher");
  104. entity.HasOne(d => d.IdCourseNavigation).WithMany(p => p.TeachersCourses)
  105. .HasForeignKey(d => d.IdCourse)
  106. .HasConstraintName("teachers_courses_fk_1");
  107. entity.HasOne(d => d.IdTeacherNavigation).WithMany(p => p.TeachersCourses)
  108. .HasForeignKey(d => d.IdTeacher)
  109. .HasConstraintName("teachers_courses_fk");
  110. });
  111. modelBuilder.Entity<User>(entity =>
  112. {
  113. entity.HasKey(e => e.IdUser).HasName("users_pk");
  114. entity.ToTable("users");
  115. entity.Property(e => e.IdUser)
  116. .UseIdentityAlwaysColumn()
  117. .HasColumnName("iduser");
  118. entity.Property(e => e.IdRole).HasColumnName("idrol");
  119. entity.Property(e => e.Login)
  120. .HasColumnType("character varying")
  121. .HasColumnName("login");
  122. entity.Property(e => e.Password)
  123. .HasColumnType("character varying")
  124. .HasColumnName("parol");
  125. entity.HasOne(d => d.IdRoleNavigation).WithMany(p => p.Users)
  126. .HasForeignKey(d => d.IdRole)
  127. .HasConstraintName("users_fk");
  128. });
  129. modelBuilder.HasSequence("courses_id_seq").HasMax(2147483647L);
  130. modelBuilder.HasSequence("genders_id_seq").HasMax(2147483647L);
  131. modelBuilder.HasSequence("roles_id_role_seq").HasMax(2147483647L);
  132. modelBuilder.HasSequence("teachers_courses_id_seq").HasMax(2147483647L);
  133. modelBuilder.HasSequence("teachers_id_seq").HasMax(2147483647L);
  134. modelBuilder.HasSequence("users_id_user_seq").HasMax(2147483647L);
  135. OnModelCreatingPartial(modelBuilder);
  136. }
  137. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  138. }