_43pBezaevaContext.cs 5.5 KB

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