SuharevaContext.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace Acosta.Models;
  5. public partial class SuharevaContext : DbContext
  6. {
  7. public SuharevaContext()
  8. {
  9. }
  10. public SuharevaContext(DbContextOptions<SuharevaContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<Acceptance> Acceptances { get; set; }
  15. public virtual DbSet<Employee> Employees { get; set; }
  16. public virtual DbSet<Outlet> Outlets { get; set; }
  17. public virtual DbSet<Product> Products { get; set; }
  18. public virtual DbSet<ProductReport> ProductReports { get; set; }
  19. public virtual DbSet<Project> Projects { get; set; }
  20. public virtual DbSet<ProjectsAndEmployee> ProjectsAndEmployees { get; set; }
  21. public virtual DbSet<ProjectsAndOutlet> ProjectsAndOutlets { get; set; }
  22. public virtual DbSet<Role> Roles { get; set; }
  23. public virtual DbSet<TradeNetwork> TradeNetworks { get; set; }
  24. public virtual DbSet<Visit> Visits { get; set; }
  25. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  26. #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.
  27. => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.ru;Port=5442;Database=Suhareva;Username=33P;Password=12345");
  28. protected override void OnModelCreating(ModelBuilder modelBuilder)
  29. {
  30. modelBuilder.Entity<Acceptance>(entity =>
  31. {
  32. entity.HasKey(e => e.Acceptanceid).HasName("Acceptance_pkey");
  33. entity.ToTable("Acceptance");
  34. entity.Property(e => e.Acceptanceid)
  35. .UseIdentityAlwaysColumn()
  36. .HasColumnName("acceptanceid");
  37. entity.Property(e => e.Title)
  38. .HasMaxLength(30)
  39. .HasColumnName("title");
  40. });
  41. modelBuilder.Entity<Employee>(entity =>
  42. {
  43. entity.HasKey(e => e.Employeesid).HasName("Employees_pkey");
  44. entity.Property(e => e.Employeesid)
  45. .UseIdentityAlwaysColumn()
  46. .HasColumnName("employeesid");
  47. entity.Property(e => e.Email)
  48. .HasMaxLength(30)
  49. .HasColumnName("email");
  50. entity.Property(e => e.Name)
  51. .HasMaxLength(30)
  52. .HasColumnName("name");
  53. entity.Property(e => e.Password)
  54. .HasMaxLength(30)
  55. .HasColumnName("password");
  56. entity.Property(e => e.Patronymic)
  57. .HasMaxLength(30)
  58. .HasColumnName("patronymic");
  59. entity.Property(e => e.Phonenumber)
  60. .HasMaxLength(30)
  61. .HasColumnName("phonenumber");
  62. entity.Property(e => e.Role).HasColumnName("role");
  63. entity.Property(e => e.Surname)
  64. .HasMaxLength(30)
  65. .HasColumnName("surname");
  66. entity.HasOne(d => d.RoleNavigation).WithMany(p => p.Employees)
  67. .HasForeignKey(d => d.Role)
  68. .OnDelete(DeleteBehavior.ClientSetNull)
  69. .HasConstraintName("Employees_role_fkey");
  70. });
  71. modelBuilder.Entity<Outlet>(entity =>
  72. {
  73. entity.HasKey(e => e.Outletid).HasName("Outlets_pkey");
  74. entity.Property(e => e.Outletid)
  75. .UseIdentityAlwaysColumn()
  76. .HasColumnName("outletid");
  77. entity.Property(e => e.Address)
  78. .HasMaxLength(100)
  79. .HasColumnName("address");
  80. entity.Property(e => e.Location)
  81. .HasMaxLength(100)
  82. .HasColumnName("location");
  83. entity.Property(e => e.TradeNetworks).HasColumnName("Trade networks");
  84. entity.HasOne(d => d.TradeNetworksNavigation).WithMany(p => p.Outlets)
  85. .HasForeignKey(d => d.TradeNetworks)
  86. .OnDelete(DeleteBehavior.ClientSetNull)
  87. .HasConstraintName("Outlets_Trade networks_fkey");
  88. });
  89. modelBuilder.Entity<Product>(entity =>
  90. {
  91. entity.HasKey(e => e.Productid).HasName("Products_pkey");
  92. entity.Property(e => e.Productid)
  93. .UseIdentityAlwaysColumn()
  94. .HasColumnName("productid");
  95. entity.Property(e => e.Project).HasColumnName("project");
  96. entity.Property(e => e.Title)
  97. .HasMaxLength(100)
  98. .HasColumnName("title");
  99. entity.HasOne(d => d.ProjectNavigation).WithMany(p => p.Products)
  100. .HasForeignKey(d => d.Project)
  101. .OnDelete(DeleteBehavior.ClientSetNull)
  102. .HasConstraintName("Products_project_fkey");
  103. });
  104. modelBuilder.Entity<ProductReport>(entity =>
  105. {
  106. entity.HasKey(e => e.Productreportid).HasName("Product reports_pkey");
  107. entity.ToTable("Product reports");
  108. entity.Property(e => e.Productreportid)
  109. .UseIdentityAlwaysColumn()
  110. .HasColumnName("productreportid");
  111. entity.Property(e => e.Actualbalance).HasColumnName("actualbalance");
  112. entity.Property(e => e.Price).HasColumnName("price");
  113. entity.Property(e => e.Pricetothecard).HasColumnName("pricetothecard");
  114. entity.Property(e => e.Product).HasColumnName("product");
  115. entity.Property(e => e.Virtualbalance).HasColumnName("virtualbalance");
  116. entity.Property(e => e.Visit).HasColumnName("visit");
  117. entity.HasOne(d => d.ProductNavigation).WithMany(p => p.ProductReports)
  118. .HasForeignKey(d => d.Product)
  119. .OnDelete(DeleteBehavior.ClientSetNull)
  120. .HasConstraintName("Product reports_product_fkey");
  121. entity.HasOne(d => d.VisitNavigation).WithMany(p => p.ProductReports)
  122. .HasForeignKey(d => d.Visit)
  123. .OnDelete(DeleteBehavior.ClientSetNull)
  124. .HasConstraintName("Product reports_visit_fkey");
  125. });
  126. modelBuilder.Entity<Project>(entity =>
  127. {
  128. entity.HasKey(e => e.Projectid).HasName("Projects_pkey");
  129. entity.Property(e => e.Projectid)
  130. .UseIdentityAlwaysColumn()
  131. .HasColumnName("projectid");
  132. entity.Property(e => e.Numofvisitsperweek).HasColumnName("numofvisitsperweek");
  133. entity.Property(e => e.Title)
  134. .HasMaxLength(30)
  135. .HasColumnName("title");
  136. });
  137. modelBuilder.Entity<ProjectsAndEmployee>(entity =>
  138. {
  139. entity
  140. .HasNoKey()
  141. .ToTable("Projects and employees");
  142. entity.Property(e => e.Employeeid).HasColumnName("employeeid");
  143. entity.Property(e => e.Projectid).HasColumnName("projectid");
  144. entity.HasOne(d => d.Employee).WithMany()
  145. .HasForeignKey(d => d.Employeeid)
  146. .OnDelete(DeleteBehavior.ClientSetNull)
  147. .HasConstraintName("Projects and employees_employeeid_fkey");
  148. entity.HasOne(d => d.Project).WithMany()
  149. .HasForeignKey(d => d.Projectid)
  150. .OnDelete(DeleteBehavior.ClientSetNull)
  151. .HasConstraintName("Projects and employees_projectid_fkey");
  152. });
  153. modelBuilder.Entity<ProjectsAndOutlet>(entity =>
  154. {
  155. entity
  156. .HasNoKey()
  157. .ToTable("Projects and outlets");
  158. entity.Property(e => e.Outletid).HasColumnName("outletid");
  159. entity.Property(e => e.Projectid).HasColumnName("projectid");
  160. entity.HasOne(d => d.Outlet).WithMany()
  161. .HasForeignKey(d => d.Outletid)
  162. .OnDelete(DeleteBehavior.ClientSetNull)
  163. .HasConstraintName("Projects and outlets_outletid_fkey");
  164. entity.HasOne(d => d.Project).WithMany()
  165. .HasForeignKey(d => d.Projectid)
  166. .OnDelete(DeleteBehavior.ClientSetNull)
  167. .HasConstraintName("Projects and outlets_projectid_fkey");
  168. });
  169. modelBuilder.Entity<Role>(entity =>
  170. {
  171. entity.HasKey(e => e.Roleid).HasName("Roles_pkey");
  172. entity.Property(e => e.Roleid)
  173. .UseIdentityAlwaysColumn()
  174. .HasColumnName("roleid");
  175. entity.Property(e => e.Title)
  176. .HasMaxLength(30)
  177. .HasColumnName("title");
  178. });
  179. modelBuilder.Entity<TradeNetwork>(entity =>
  180. {
  181. entity.HasKey(e => e.Tradeid).HasName("Trade networks_pkey");
  182. entity.ToTable("Trade networks");
  183. entity.Property(e => e.Tradeid)
  184. .UseIdentityAlwaysColumn()
  185. .HasColumnName("tradeid");
  186. entity.Property(e => e.Title)
  187. .HasMaxLength(30)
  188. .HasColumnName("title");
  189. });
  190. modelBuilder.Entity<Visit>(entity =>
  191. {
  192. entity.HasKey(e => e.Visitid).HasName("Visits_pkey");
  193. entity.Property(e => e.Visitid)
  194. .UseIdentityAlwaysColumn()
  195. .HasColumnName("visitid");
  196. entity.Property(e => e.Accepted).HasColumnName("accepted");
  197. entity.Property(e => e.Merchcomment)
  198. .HasMaxLength(200)
  199. .HasColumnName("merchcomment");
  200. entity.Property(e => e.Outlet).HasColumnName("outlet");
  201. entity.Property(e => e.Project).HasColumnName("project");
  202. entity.Property(e => e.Visitdate).HasColumnName("visitdate");
  203. entity.Property(e => e.Visittime).HasColumnName("visittime");
  204. entity.HasOne(d => d.AcceptedNavigation).WithMany(p => p.Visits)
  205. .HasForeignKey(d => d.Accepted)
  206. .OnDelete(DeleteBehavior.ClientSetNull)
  207. .HasConstraintName("Visits_accepted_fkey");
  208. entity.HasOne(d => d.OutletNavigation).WithMany(p => p.Visits)
  209. .HasForeignKey(d => d.Outlet)
  210. .OnDelete(DeleteBehavior.ClientSetNull)
  211. .HasConstraintName("Visits_outlet_fkey");
  212. entity.HasOne(d => d.ProjectNavigation).WithMany(p => p.Visits)
  213. .HasForeignKey(d => d.Project)
  214. .OnDelete(DeleteBehavior.ClientSetNull)
  215. .HasConstraintName("Visits_project_fkey");
  216. });
  217. OnModelCreatingPartial(modelBuilder);
  218. }
  219. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  220. }