_41pAgeevNContext.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace ApplicationAvalonia.Models;
  5. public partial class _41pAgeevNContext : DbContext
  6. {
  7. public _41pAgeevNContext()
  8. {
  9. }
  10. public _41pAgeevNContext(DbContextOptions<_41pAgeevNContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<Director> Directors { get; set; }
  15. public virtual DbSet<DirectorsAndFilm> DirectorsAndFilms { get; set; }
  16. public virtual DbSet<Film> Films { get; set; }
  17. public virtual DbSet<FilmAndGenre> FilmAndGenres { get; set; }
  18. public virtual DbSet<Genre> Genres { get; set; }
  19. public virtual DbSet<LoginTable> LoginTables { get; set; }
  20. public virtual DbSet<Role> Roles { get; set; }
  21. public virtual DbSet<UserTable> UserTables { get; set; }
  22. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  23. #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.
  24. => optionsBuilder.UseNpgsql("Host=ngknn.ru;Port=5442;Username=41P;Password=12357;Database=41P_AgeevN");
  25. protected override void OnModelCreating(ModelBuilder modelBuilder)
  26. {
  27. modelBuilder.Entity<Director>(entity =>
  28. {
  29. entity.HasKey(e => e.Id).HasName("directors_pk");
  30. entity.ToTable("directors");
  31. entity.Property(e => e.Id).HasColumnName("id");
  32. entity.Property(e => e.Name)
  33. .HasColumnType("character varying")
  34. .HasColumnName("name");
  35. entity.Property(e => e.Surname)
  36. .HasColumnType("character varying")
  37. .HasColumnName("surname");
  38. });
  39. modelBuilder.Entity<DirectorsAndFilm>(entity =>
  40. {
  41. entity.HasKey(e => e.Id).HasName("directors_and_films_pk");
  42. entity.ToTable("directors_and_films");
  43. entity.Property(e => e.Id).HasColumnName("id");
  44. entity.Property(e => e.IdDirector)
  45. .ValueGeneratedOnAdd()
  46. .HasColumnName("id_director");
  47. entity.Property(e => e.IdFilm)
  48. .ValueGeneratedOnAdd()
  49. .HasColumnName("id_film");
  50. entity.HasOne(d => d.IdDirectorNavigation).WithMany(p => p.DirectorsAndFilms)
  51. .HasForeignKey(d => d.IdDirector)
  52. .OnDelete(DeleteBehavior.ClientSetNull)
  53. .HasConstraintName("directors_and_films_directors_fk");
  54. entity.HasOne(d => d.IdFilmNavigation).WithMany(p => p.DirectorsAndFilms)
  55. .HasForeignKey(d => d.IdFilm)
  56. .OnDelete(DeleteBehavior.ClientSetNull)
  57. .HasConstraintName("directors_and_films_films_fk");
  58. });
  59. modelBuilder.Entity<Film>(entity =>
  60. {
  61. entity.HasKey(e => e.Id).HasName("films_pkey");
  62. entity.ToTable("films");
  63. entity.Property(e => e.Id).HasColumnName("id");
  64. entity.Property(e => e.Description).HasColumnName("description");
  65. entity.Property(e => e.Duration)
  66. .HasColumnType("character varying")
  67. .HasColumnName("duration");
  68. entity.Property(e => e.Image)
  69. .HasColumnType("character varying")
  70. .HasColumnName("image");
  71. entity.Property(e => e.Name)
  72. .HasMaxLength(50)
  73. .HasColumnName("name");
  74. entity.Property(e => e.Raiting).HasColumnName("raiting");
  75. entity.Property(e => e.Trailer)
  76. .HasColumnType("character varying")
  77. .HasColumnName("trailer");
  78. });
  79. modelBuilder.Entity<FilmAndGenre>(entity =>
  80. {
  81. entity.HasKey(e => e.Id).HasName("film_and_genre_pkey");
  82. entity.ToTable("film_and_genre");
  83. entity.Property(e => e.Id).HasColumnName("id");
  84. entity.Property(e => e.FilmId)
  85. .ValueGeneratedOnAdd()
  86. .HasColumnName("film_id");
  87. entity.Property(e => e.GenreId)
  88. .ValueGeneratedOnAdd()
  89. .HasColumnName("genre_id");
  90. entity.HasOne(d => d.Film).WithMany(p => p.FilmAndGenres)
  91. .HasForeignKey(d => d.FilmId)
  92. .OnDelete(DeleteBehavior.ClientSetNull)
  93. .HasConstraintName("film_and_genre_film_id_fkey");
  94. entity.HasOne(d => d.Genre).WithMany(p => p.FilmAndGenres)
  95. .HasForeignKey(d => d.GenreId)
  96. .OnDelete(DeleteBehavior.ClientSetNull)
  97. .HasConstraintName("film_and_genre_genre_id_fkey");
  98. });
  99. modelBuilder.Entity<Genre>(entity =>
  100. {
  101. entity.HasKey(e => e.Id).HasName("genders_pkey");
  102. entity.ToTable("genres");
  103. entity.Property(e => e.Id)
  104. .HasDefaultValueSql("nextval('genders_id_seq'::regclass)")
  105. .HasColumnName("id");
  106. entity.Property(e => e.GenreName)
  107. .HasColumnType("character varying")
  108. .HasColumnName("genre_name");
  109. });
  110. modelBuilder.Entity<LoginTable>(entity =>
  111. {
  112. entity.HasKey(e => e.Id).HasName("login_table_pkey");
  113. entity.ToTable("login_table");
  114. entity.HasIndex(e => e.Login, "login_table_unique").IsUnique();
  115. entity.Property(e => e.Id).HasColumnName("id");
  116. entity.Property(e => e.Iv).HasColumnName("iv");
  117. entity.Property(e => e.Key).HasColumnName("key");
  118. entity.Property(e => e.Login)
  119. .HasColumnType("character varying")
  120. .HasColumnName("login");
  121. entity.Property(e => e.Password).HasColumnName("password");
  122. });
  123. modelBuilder.Entity<Role>(entity =>
  124. {
  125. entity.HasKey(e => e.Id).HasName("roles_pk");
  126. entity.ToTable("roles");
  127. entity.Property(e => e.Id).HasColumnName("id");
  128. entity.Property(e => e.Title)
  129. .HasColumnType("character varying")
  130. .HasColumnName("title");
  131. });
  132. modelBuilder.Entity<UserTable>(entity =>
  133. {
  134. entity.HasKey(e => e.IdLogin).HasName("user_table_pk");
  135. entity.ToTable("user_table");
  136. entity.Property(e => e.IdLogin)
  137. .ValueGeneratedOnAdd()
  138. .HasColumnName("id_login");
  139. entity.Property(e => e.IdRole)
  140. .ValueGeneratedOnAdd()
  141. .HasColumnName("id_role");
  142. entity.Property(e => e.UserName)
  143. .HasMaxLength(40)
  144. .HasColumnName("user_name");
  145. entity.Property(e => e.UserSurname)
  146. .HasMaxLength(40)
  147. .HasColumnName("user_surname");
  148. entity.HasOne(d => d.IdLoginNavigation).WithOne(p => p.UserTable)
  149. .HasForeignKey<UserTable>(d => d.IdLogin)
  150. .OnDelete(DeleteBehavior.ClientSetNull)
  151. .HasConstraintName("user_table_id_login_fkey");
  152. entity.HasOne(d => d.IdRoleNavigation).WithMany(p => p.UserTables)
  153. .HasForeignKey(d => d.IdRole)
  154. .OnDelete(DeleteBehavior.ClientSetNull)
  155. .HasConstraintName("user_table_roles_fk");
  156. });
  157. OnModelCreatingPartial(modelBuilder);
  158. }
  159. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  160. }