VorobiewTradeContext.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace OOO_WriteAndClear.DBModels;
  5. public partial class VorobiewTradeContext : DbContext
  6. {
  7. public VorobiewTradeContext()
  8. {
  9. }
  10. public VorobiewTradeContext(DbContextOptions<VorobiewTradeContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<Category> Categories { get; set; }
  15. public virtual DbSet<Manufacturer> Manufacturers { get; set; }
  16. public virtual DbSet<Measurment> Measurments { get; set; }
  17. public virtual DbSet<Order> Orders { get; set; }
  18. public virtual DbSet<OrderProduct> OrderProducts { get; set; }
  19. public virtual DbSet<OrderStatus> OrderStatuses { get; set; }
  20. public virtual DbSet<PickupPoint> PickupPoints { get; set; }
  21. public virtual DbSet<Product> Products { get; set; }
  22. public virtual DbSet<Role> Roles { get; set; }
  23. public virtual DbSet<Supplier> Suppliers { get; set; }
  24. public virtual DbSet<User> Users { 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.UseSqlServer("Server=ngknn.ru;Database=VorobiewTrade;user id=23П;Password=12357;Trusted_Connection=false;TrustServerCertificate=Yes;");
  28. //optionsBuilder.UseSqlServer("Server=sql;Database=VorobiewTrade;user id=23П;Password=12357;Trusted_Connection=false;TrustServerCertificate=Yes;");
  29. protected override void OnModelCreating(ModelBuilder modelBuilder)
  30. {
  31. modelBuilder.Entity<Category>(entity =>
  32. {
  33. entity.ToTable("Category");
  34. entity.Property(e => e.CategoryId).HasColumnName("CategoryID");
  35. });
  36. modelBuilder.Entity<Manufacturer>(entity =>
  37. {
  38. entity.ToTable("Manufacturer");
  39. entity.Property(e => e.ManufacturerId).HasColumnName("ManufacturerID");
  40. });
  41. modelBuilder.Entity<Measurment>(entity =>
  42. {
  43. entity.ToTable("Measurment");
  44. entity.Property(e => e.MeasurmentId).HasColumnName("MeasurmentID");
  45. entity.Property(e => e.MeasurmentName).IsUnicode(false);
  46. });
  47. modelBuilder.Entity<Order>(entity =>
  48. {
  49. entity.HasKey(e => e.OrderId).HasName("PK__Order__C3905BAF2D5AB59F");
  50. entity.ToTable("Order");
  51. entity.Property(e => e.OrderId).HasColumnName("OrderID");
  52. entity.Property(e => e.OrderCreateDate).HasColumnType("datetime");
  53. entity.Property(e => e.OrderCustomer).IsUnicode(false);
  54. entity.Property(e => e.OrderDeliveryDate).HasColumnType("datetime");
  55. entity.Property(e => e.OrderPickupPointId).HasColumnName("OrderPickupPointID");
  56. entity.Property(e => e.OrderStatusId).HasColumnName("OrderStatusID");
  57. entity.HasOne(d => d.OrderPickupPoint).WithMany(p => p.Orders)
  58. .HasForeignKey(d => d.OrderPickupPointId)
  59. .OnDelete(DeleteBehavior.ClientSetNull)
  60. .HasConstraintName("FK_Order_PickupPoint");
  61. entity.HasOne(d => d.OrderStatus).WithMany(p => p.Orders)
  62. .HasForeignKey(d => d.OrderStatusId)
  63. .HasConstraintName("FK_Order_OrderStatus");
  64. });
  65. modelBuilder.Entity<OrderProduct>(entity =>
  66. {
  67. entity.HasKey(e => new { e.OrderId, e.ProductArticleNumber }).HasName("PK__OrderPro__817A2662A7A59993");
  68. entity.ToTable("OrderProduct");
  69. entity.Property(e => e.OrderId).HasColumnName("OrderID");
  70. entity.Property(e => e.ProductArticleNumber).HasMaxLength(100);
  71. entity.HasOne(d => d.Order).WithMany(p => p.OrderProducts)
  72. .HasForeignKey(d => d.OrderId)
  73. .OnDelete(DeleteBehavior.ClientSetNull)
  74. .HasConstraintName("FK__OrderProd__Order__403A8C7D");
  75. entity.HasOne(d => d.ProductArticleNumberNavigation).WithMany(p => p.OrderProducts)
  76. .HasForeignKey(d => d.ProductArticleNumber)
  77. .OnDelete(DeleteBehavior.ClientSetNull)
  78. .HasConstraintName("FK__OrderProd__Produ__412EB0B6");
  79. });
  80. modelBuilder.Entity<OrderStatus>(entity =>
  81. {
  82. entity.ToTable("OrderStatus");
  83. entity.Property(e => e.OrderStatusId).HasColumnName("OrderStatusID");
  84. });
  85. modelBuilder.Entity<PickupPoint>(entity =>
  86. {
  87. entity.ToTable("PickupPoint");
  88. entity.Property(e => e.PickupPointId).HasColumnName("PickupPointID");
  89. });
  90. modelBuilder.Entity<Product>(entity =>
  91. {
  92. entity.HasKey(e => e.ProductArticleNumber).HasName("PK__Product__2EA7DCD5BDE5BBCB");
  93. entity.ToTable("Product");
  94. entity.Property(e => e.ProductArticleNumber).HasMaxLength(100);
  95. entity.Property(e => e.CategoryId).HasColumnName("CategoryID");
  96. entity.Property(e => e.ProductCost).HasColumnType("decimal(19, 4)");
  97. entity.Property(e => e.ProductDiscountAmount).HasColumnType("decimal(19, 4)");
  98. entity.Property(e => e.ProductManufacturerId).HasColumnName("ProductManufacturerID");
  99. entity.Property(e => e.ProductMeasurmentId).HasColumnName("ProductMeasurmentID");
  100. entity.Property(e => e.ProductPhoto).HasColumnType("text");
  101. entity.Property(e => e.ProductSuppliarId).HasColumnName("ProductSuppliarID");
  102. entity.HasOne(d => d.Category).WithMany(p => p.Products)
  103. .HasForeignKey(d => d.CategoryId)
  104. .HasConstraintName("FK_Product_Category");
  105. entity.HasOne(d => d.ProductManufacturer).WithMany(p => p.Products)
  106. .HasForeignKey(d => d.ProductManufacturerId)
  107. .HasConstraintName("FK_Product_Manufacturer");
  108. entity.HasOne(d => d.ProductMeasurment).WithMany(p => p.Products)
  109. .HasForeignKey(d => d.ProductMeasurmentId)
  110. .HasConstraintName("FK_Product_Measurment");
  111. entity.HasOne(d => d.ProductSuppliar).WithMany(p => p.Products)
  112. .HasForeignKey(d => d.ProductSuppliarId)
  113. .HasConstraintName("FK_Product_Supplier");
  114. });
  115. modelBuilder.Entity<Role>(entity =>
  116. {
  117. entity.HasKey(e => e.RoleId).HasName("PK__Role__8AFACE3A7F79F8C2");
  118. entity.ToTable("Role");
  119. entity.Property(e => e.RoleId).HasColumnName("RoleID");
  120. entity.Property(e => e.RoleName).HasMaxLength(100);
  121. });
  122. modelBuilder.Entity<Supplier>(entity =>
  123. {
  124. entity.HasKey(e => e.SuppliarId);
  125. entity.ToTable("Supplier");
  126. entity.Property(e => e.SuppliarId).HasColumnName("SuppliarID");
  127. entity.Property(e => e.SuppliarName).IsUnicode(false);
  128. });
  129. modelBuilder.Entity<User>(entity =>
  130. {
  131. entity.HasKey(e => e.UserId).HasName("PK__User__1788CCACA92938ED");
  132. entity.ToTable("User");
  133. entity.Property(e => e.UserId).HasColumnName("UserID");
  134. entity.Property(e => e.UserName).HasMaxLength(100);
  135. entity.Property(e => e.UserPatronymic).HasMaxLength(100);
  136. entity.Property(e => e.UserSurname).HasMaxLength(100);
  137. entity.HasOne(d => d.UserRoleNavigation).WithMany(p => p.Users)
  138. .HasForeignKey(d => d.UserRole)
  139. .OnDelete(DeleteBehavior.ClientSetNull)
  140. .HasConstraintName("FK__User__UserRole__398D8EEE");
  141. });
  142. OnModelCreatingPartial(modelBuilder);
  143. }
  144. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  145. }