123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- using System;
- using System.Collections.Generic;
- using Microsoft.EntityFrameworkCore;
- namespace OOO_WriteAndClear.DBModels;
- public partial class VorobiewTradeContext : DbContext
- {
- public VorobiewTradeContext()
- {
- }
- public VorobiewTradeContext(DbContextOptions<VorobiewTradeContext> options)
- : base(options)
- {
- }
- public virtual DbSet<Category> Categories { get; set; }
- public virtual DbSet<Manufacturer> Manufacturers { get; set; }
- public virtual DbSet<Measurment> Measurments { get; set; }
- public virtual DbSet<Order> Orders { get; set; }
- public virtual DbSet<OrderProduct> OrderProducts { get; set; }
- public virtual DbSet<OrderStatus> OrderStatuses { get; set; }
- public virtual DbSet<PickupPoint> PickupPoints { get; set; }
- public virtual DbSet<Product> Products { get; set; }
- public virtual DbSet<Role> Roles { get; set; }
- public virtual DbSet<Supplier> Suppliers { get; set; }
- public virtual DbSet<User> Users { get; set; }
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- #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.
- => optionsBuilder.UseSqlServer("Server=ngknn.ru;Database=VorobiewTrade;user id=23П;Password=12357;Trusted_Connection=false;TrustServerCertificate=Yes;");
- //optionsBuilder.UseSqlServer("Server=sql;Database=VorobiewTrade;user id=23П;Password=12357;Trusted_Connection=false;TrustServerCertificate=Yes;");
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.Entity<Category>(entity =>
- {
- entity.ToTable("Category");
- entity.Property(e => e.CategoryId).HasColumnName("CategoryID");
- });
- modelBuilder.Entity<Manufacturer>(entity =>
- {
- entity.ToTable("Manufacturer");
- entity.Property(e => e.ManufacturerId).HasColumnName("ManufacturerID");
- });
- modelBuilder.Entity<Measurment>(entity =>
- {
- entity.ToTable("Measurment");
- entity.Property(e => e.MeasurmentId).HasColumnName("MeasurmentID");
- entity.Property(e => e.MeasurmentName).IsUnicode(false);
- });
- modelBuilder.Entity<Order>(entity =>
- {
- entity.HasKey(e => e.OrderId).HasName("PK__Order__C3905BAF2D5AB59F");
- entity.ToTable("Order");
- entity.Property(e => e.OrderId).HasColumnName("OrderID");
- entity.Property(e => e.OrderCreateDate).HasColumnType("datetime");
- entity.Property(e => e.OrderCustomer).IsUnicode(false);
- entity.Property(e => e.OrderDeliveryDate).HasColumnType("datetime");
- entity.Property(e => e.OrderPickupPointId).HasColumnName("OrderPickupPointID");
- entity.Property(e => e.OrderStatusId).HasColumnName("OrderStatusID");
- entity.HasOne(d => d.OrderPickupPoint).WithMany(p => p.Orders)
- .HasForeignKey(d => d.OrderPickupPointId)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("FK_Order_PickupPoint");
- entity.HasOne(d => d.OrderStatus).WithMany(p => p.Orders)
- .HasForeignKey(d => d.OrderStatusId)
- .HasConstraintName("FK_Order_OrderStatus");
- });
- modelBuilder.Entity<OrderProduct>(entity =>
- {
- entity.HasKey(e => new { e.OrderId, e.ProductArticleNumber }).HasName("PK__OrderPro__817A2662A7A59993");
- entity.ToTable("OrderProduct");
- entity.Property(e => e.OrderId).HasColumnName("OrderID");
- entity.Property(e => e.ProductArticleNumber).HasMaxLength(100);
- entity.HasOne(d => d.Order).WithMany(p => p.OrderProducts)
- .HasForeignKey(d => d.OrderId)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("FK__OrderProd__Order__403A8C7D");
- entity.HasOne(d => d.ProductArticleNumberNavigation).WithMany(p => p.OrderProducts)
- .HasForeignKey(d => d.ProductArticleNumber)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("FK__OrderProd__Produ__412EB0B6");
- });
- modelBuilder.Entity<OrderStatus>(entity =>
- {
- entity.ToTable("OrderStatus");
- entity.Property(e => e.OrderStatusId).HasColumnName("OrderStatusID");
- });
- modelBuilder.Entity<PickupPoint>(entity =>
- {
- entity.ToTable("PickupPoint");
- entity.Property(e => e.PickupPointId).HasColumnName("PickupPointID");
- });
- modelBuilder.Entity<Product>(entity =>
- {
- entity.HasKey(e => e.ProductArticleNumber).HasName("PK__Product__2EA7DCD5BDE5BBCB");
- entity.ToTable("Product");
- entity.Property(e => e.ProductArticleNumber).HasMaxLength(100);
- entity.Property(e => e.CategoryId).HasColumnName("CategoryID");
- entity.Property(e => e.ProductCost).HasColumnType("decimal(19, 4)");
- entity.Property(e => e.ProductDiscountAmount).HasColumnType("decimal(19, 4)");
- entity.Property(e => e.ProductManufacturerId).HasColumnName("ProductManufacturerID");
- entity.Property(e => e.ProductMeasurmentId).HasColumnName("ProductMeasurmentID");
- entity.Property(e => e.ProductPhoto).HasColumnType("text");
- entity.Property(e => e.ProductSuppliarId).HasColumnName("ProductSuppliarID");
- entity.HasOne(d => d.Category).WithMany(p => p.Products)
- .HasForeignKey(d => d.CategoryId)
- .HasConstraintName("FK_Product_Category");
- entity.HasOne(d => d.ProductManufacturer).WithMany(p => p.Products)
- .HasForeignKey(d => d.ProductManufacturerId)
- .HasConstraintName("FK_Product_Manufacturer");
- entity.HasOne(d => d.ProductMeasurment).WithMany(p => p.Products)
- .HasForeignKey(d => d.ProductMeasurmentId)
- .HasConstraintName("FK_Product_Measurment");
- entity.HasOne(d => d.ProductSuppliar).WithMany(p => p.Products)
- .HasForeignKey(d => d.ProductSuppliarId)
- .HasConstraintName("FK_Product_Supplier");
- });
- modelBuilder.Entity<Role>(entity =>
- {
- entity.HasKey(e => e.RoleId).HasName("PK__Role__8AFACE3A7F79F8C2");
- entity.ToTable("Role");
- entity.Property(e => e.RoleId).HasColumnName("RoleID");
- entity.Property(e => e.RoleName).HasMaxLength(100);
- });
- modelBuilder.Entity<Supplier>(entity =>
- {
- entity.HasKey(e => e.SuppliarId);
- entity.ToTable("Supplier");
- entity.Property(e => e.SuppliarId).HasColumnName("SuppliarID");
- entity.Property(e => e.SuppliarName).IsUnicode(false);
- });
- modelBuilder.Entity<User>(entity =>
- {
- entity.HasKey(e => e.UserId).HasName("PK__User__1788CCACA92938ED");
- entity.ToTable("User");
- entity.Property(e => e.UserId).HasColumnName("UserID");
- entity.Property(e => e.UserName).HasMaxLength(100);
- entity.Property(e => e.UserPatronymic).HasMaxLength(100);
- entity.Property(e => e.UserSurname).HasMaxLength(100);
- entity.HasOne(d => d.UserRoleNavigation).WithMany(p => p.Users)
- .HasForeignKey(d => d.UserRole)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("FK__User__UserRole__398D8EEE");
- });
- OnModelCreatingPartial(modelBuilder);
- }
- partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
- }
|