BaseDbContext.cs 19.4 KB
using System.Data.SqlClient;
using Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;

namespace WebRepository
{
    public partial class BaseDBContext: DbContext
    {
        public BaseDBContext(DbContextOptions<BaseDBContext> options, IConfiguration configuration) : base(options)
        {
            string ConnString = configuration.GetConnectionString("BaseDBContext");
            SqlConnectionStringBuilder sqlConnectionStringBuilder = new SqlConnectionStringBuilder(ConnString);
            string enpwd = Encryption.Encrypt("abc123*");
            sqlConnectionStringBuilder.Password = Encryption.Decrypt(sqlConnectionStringBuilder.Password);
            Database.GetDbConnection().ConnectionString = sqlConnectionStringBuilder.ConnectionString;
        }

        public virtual DbSet<Container> Containers { get; set; }
        public virtual DbSet<Customer> Customers { get; set; }
        public virtual DbSet<CyclecountAdjust> CyclecountAdjusts { get; set; }
        public virtual DbSet<CyclecountAdjustdetail> CyclecountAdjustdetails { get; set; }
        public virtual DbSet<CyclecountDetail> CyclecountDetails { get; set; }
        public virtual DbSet<CyclecountHeader> CyclecountHeaders { get; set; }
        public virtual DbSet<Excelreport> Excelreports { get; set; }
        public virtual DbSet<Inventory> Inventories { get; set; }
        public virtual DbSet<InventoryTransaction> InventoryTransactions { get; set; }
        public virtual DbSet<IreceiptDetail> IreceiptDetails { get; set; }
        public virtual DbSet<IreceiptHeader> IreceiptHeaders { get; set; }
        public virtual DbSet<IshipmentDetail> IshipmentDetails { get; set; }
        public virtual DbSet<IshipmentHeader> IshipmentHeaders { get; set; }
        public virtual DbSet<Location> Locations { get; set; }
        public virtual DbSet<Machine> Machines { get; set; }
        public virtual DbSet<Material> Materials { get; set; }
        public virtual DbSet<Station> Stations { get; set; }
        public virtual DbSet<StationToStation> StationToStation { get; set; }
        public virtual DbSet<StationRoadway> StationRoadways { get; set; }
        public virtual DbSet<ReceiptDetail> ReceiptDetails { get; set; }
        public virtual DbSet<ReceiptDetailHistory> ReceiptDetailHistories { get; set; }
        public virtual DbSet<ReceiptHeader> ReceiptHeaders { get; set; }
        public virtual DbSet<ReceiptHeaderHistory> ReceiptHeaderHistories { get; set; }
        public virtual DbSet<ReceiptContainerDetail> ReceiptContainerDetails { get; set; }
        public virtual DbSet<ReceiptContainerHeader> ReceiptContainerHeaders { get; set; }
        public virtual DbSet<ShipmentDetail> ShipmentDetails { get; set; }
        public virtual DbSet<ShipmentDetailHistory> ShipmentDetailHistories { get; set; }
        public virtual DbSet<ShipmentHeader> ShipmentHeaders { get; set; }
        public virtual DbSet<ShipmentHeaderHistory> ShipmentHeaderHistories { get; set; }
        public virtual DbSet<ShipmentContainerDetail> ShipmentContainerDetails { get; set; }
        public virtual DbSet<ShipmentContainerHeader> ShipmentContainerHeaders { get; set; }
        public virtual DbSet<Supplier> Suppliers { get; set; }
        public virtual DbSet<SysDept> SysDepts { get; set; }
        public virtual DbSet<SysDictData> SysDictDatas { get; set; }
        public virtual DbSet<SysDictType> SysDictTypes { get; set; }
        public virtual DbSet<SysInfo> SysInfos { get; set; }
        public virtual DbSet<SysInterfaceLog> SysInterfaceLogs { get; set; }
        public virtual DbSet<SysJob> SysJobs { get; set; }
        public virtual DbSet<SysJobLog> SysJobLogs { get; set; }
        public virtual DbSet<SysLoginLog> SysLoginLogs { get; set; }
        public virtual DbSet<SysModule> SysModules { get; set; }
        public virtual DbSet<SysModuleElement> SysModuleElements { get; set; }
        public virtual DbSet<SysOperLog> SysOperLogs { get; set; }
        public virtual DbSet<SysRelevance> SysRelevances { get; set; }
        public virtual DbSet<SysRole> SysRoles { get; set; }
        public virtual DbSet<SysUser> SysUsers { get; set; }
        public virtual DbSet<SysUserOnline> SysUserOnlines { get; set; }
        public virtual DbSet<Task> Tasks { get; set; }
        public virtual DbSet<TaskDetail> TaskDetails { get; set; }
        public virtual DbSet<TaskDetailHistory> TaskDetailHistories { get; set; }
        public virtual DbSet<TaskHistory> TaskHistories { get; set; }
        public virtual DbSet<WcsBaseStore> WcsBaseStores { get; set; }
        public virtual DbSet<WcsBaseWareCell> WcsBaseWareCells { get; set; }
        public virtual DbSet<WcsDevice> WcsDevices { get; set; }
        public virtual DbSet<WcsDeviceAddress> WcsDeviceAddresses { get; set; }
        public virtual DbSet<WcsErrorConfig> WcsErrorConfigs { get; set; }
        public virtual DbSet<WcsPose> WcsPoses { get; set; }
        public virtual DbSet<WcsSRMBuffer> WcsSRMBuffers { get; set; }
        public virtual DbSet<WcsSRMLast> WcsSRMLasts { get; set; }
        public virtual DbSet<WcsTask> WcsTasks { get; set; }
        public virtual DbSet<WcsTaskHis> WcsTaskHis { get; set; }
        public virtual DbSet<OrderAlert> OrderAlerts { get; set; }
        public virtual DbSet<SysCount> SysCounts { get; set; }
        public virtual DbSet<MachineWarecell> MachineWarecells { get; set; }
        public virtual DbSet<InventoryAlert> InventoryAlerts { get; set; }
        public virtual DbSet<TaskAlert> TaskAlerts { get; set; }
        public virtual DbSet<Cycle> Cycles { get; set; }
        public virtual DbSet<StoreStation> StoreStations { get; set; }
        public virtual DbSet<WebStart> WebStarts { get; set; }
        public virtual DbSet<LocationDistribution> LocationDistributions { get; set; }
        public virtual DbSet<InterfaceLog> InterfaceLogs { get; set; }
        public virtual DbSet<InterfaceLog_Old> InterfaceLog_Olds { get; set; }
        public virtual DbSet<ApiInterfaceLog> ApiInterfaceLogs { get; set; }
        public virtual DbSet<ApiInterfaceLog_Old> ApiInterfaceLog_Olds { get; set; }
        public virtual DbSet<InventoryOut> InventoryOuts { get; set; }

        public virtual DbSet<ApiShipmentDetail> ApiShipmentDetails { get; set; }
        public virtual DbSet<ApiShipmentDetailHistory> ApiShipmentDetailHistories { get; set; }
        public virtual DbSet<ApiShipmentHeader> ApiShipmentHeaders { get; set; }
        public virtual DbSet<ApiShipmentHeaderHistory> ApiShipmentHeaderHistories { get; set; }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            // [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
            modelBuilder.Entity<Container>().HasKey(c => c.Id);
            modelBuilder.Entity<Container>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<Customer>().HasKey(c => c.Id);
            modelBuilder.Entity<Customer>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<CyclecountAdjust>().HasKey(c => c.Id);
            modelBuilder.Entity<CyclecountAdjust>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<CyclecountAdjustdetail>().HasKey(c => c.Id);
            modelBuilder.Entity<CyclecountAdjustdetail>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<CyclecountDetail>().HasKey(c => c.Id);
            modelBuilder.Entity<CyclecountDetail>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<CyclecountHeader>().HasKey(c => c.Id);
            modelBuilder.Entity<CyclecountHeader>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<Excelreport>().HasKey(c => c.Id);
            modelBuilder.Entity<Excelreport>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<Inventory>().HasKey(c => c.Id);
            modelBuilder.Entity<Inventory>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<InventoryTransaction>().HasKey(c => c.Id);
            modelBuilder.Entity<InventoryTransaction>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<IreceiptDetail>().HasKey(c => c.Id);
            modelBuilder.Entity<IreceiptDetail>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<IreceiptHeader>().HasKey(c => c.Id);
            modelBuilder.Entity<IreceiptHeader>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<IshipmentDetail>().HasKey(c => c.Id);
            modelBuilder.Entity<IshipmentDetail>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<IshipmentHeader>().HasKey(c => c.Id);
            modelBuilder.Entity<IshipmentHeader>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<Location>().HasKey(c => c.Id);
            modelBuilder.Entity<Location>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<Machine>().HasKey(c => c.Id);
            modelBuilder.Entity<Machine>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<Material>().HasKey(c => c.Id);
            modelBuilder.Entity<Material>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<Station>().HasKey(c => c.Id);
            modelBuilder.Entity<Station>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<StationRoadway>().HasKey(c => c.Id);
            modelBuilder.Entity<StationRoadway>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<ReceiptDetail>().HasKey(c => c.Id);
            modelBuilder.Entity<ReceiptDetail>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<ReceiptDetailHistory>().HasKey(c => c.Id);
            modelBuilder.Entity<ReceiptDetailHistory>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<ReceiptHeader>().HasKey(c => c.Id);
            modelBuilder.Entity<ReceiptHeader>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<ReceiptHeaderHistory>().HasKey(c => c.Id);
            modelBuilder.Entity<ReceiptHeaderHistory>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<ReceiptContainerDetail>().HasKey(c => c.Id);
            modelBuilder.Entity<ReceiptContainerDetail>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<ReceiptContainerHeader>().HasKey(c => c.Id);
            modelBuilder.Entity<ReceiptContainerHeader>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<ShipmentDetail>().HasKey(c => c.Id);
            modelBuilder.Entity<ShipmentDetail>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<ShipmentDetailHistory>().HasKey(c => c.Id);
            modelBuilder.Entity<ShipmentDetailHistory>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<ShipmentHeader>().HasKey(c => c.Id);
            modelBuilder.Entity<ShipmentHeader>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<ShipmentHeaderHistory>().HasKey(c => c.Id);
            modelBuilder.Entity<ShipmentHeaderHistory>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<ShipmentContainerDetail>().HasKey(c => c.Id);
            modelBuilder.Entity<ShipmentContainerDetail>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<ShipmentContainerHeader>().HasKey(c => c.Id);
            modelBuilder.Entity<ShipmentContainerHeader>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<Supplier>().HasKey(c => c.Id);
            modelBuilder.Entity<Supplier>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<SysDept>().HasKey(c => c.Id);
            modelBuilder.Entity<SysDept>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<SysDictData>().HasKey(c => c.Id);
            modelBuilder.Entity<SysDictData>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<SysDictType>().HasKey(c => c.Id);
            modelBuilder.Entity<SysDictType>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<SysInfo>().HasKey(c => c.Id);
            modelBuilder.Entity<SysInfo>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<SysInterfaceLog>().HasKey(c => c.Id);
            modelBuilder.Entity<SysInterfaceLog>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<SysJob>().HasKey(c => c.Id);
            modelBuilder.Entity<SysJob>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<SysJobLog>().HasKey(c => c.Id);
            modelBuilder.Entity<SysJobLog>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<SysLoginLog>().HasKey(c => c.Id);
            modelBuilder.Entity<SysLoginLog>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<SysModule>().HasKey(c => c.Id);
            modelBuilder.Entity<SysModule>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<SysModuleElement>().HasKey(c => c.Id);
            modelBuilder.Entity<SysModuleElement>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<SysOperLog>().HasKey(c => c.Id);
            modelBuilder.Entity<SysOperLog>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<SysRelevance>().HasKey(c => c.Id);
            modelBuilder.Entity<SysRelevance>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<SysRole>().HasKey(c => c.Id);
            modelBuilder.Entity<SysRole>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<SysUser>().HasKey(c => c.Id);
            modelBuilder.Entity<SysUser>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<SysUserOnline>().HasKey(c => c.Id);
            modelBuilder.Entity<SysUserOnline>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<Task>().HasKey(c => c.Id);
            modelBuilder.Entity<Task>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<TaskDetail>().HasKey(c => c.Id);
            modelBuilder.Entity<TaskDetail>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<TaskDetailHistory>().HasKey(c => c.Id);
            modelBuilder.Entity<TaskDetailHistory>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<TaskHistory>().HasKey(c => c.Id);
            modelBuilder.Entity<TaskHistory>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<WcsBaseStore>().HasKey(c => c.Id);
            modelBuilder.Entity<WcsBaseStore>().Property(c => c.Id).HasColumnName("Id");
            
            modelBuilder.Entity<WcsBaseWareCell>().HasKey(c => c.Id);
            modelBuilder.Entity<WcsBaseWareCell>().Property(c => c.Id).HasColumnName("Id");

            modelBuilder.Entity<StationToStation>().HasKey(c => c.Id);
            modelBuilder.Entity<StationToStation>().Property(c => c.Id).HasColumnName("Id");

            modelBuilder.Entity<WcsDevice>().HasKey(c => c.Code);
            modelBuilder.Entity<WcsDevice>().Property(c => c.Code).HasColumnName("Code");
            
            modelBuilder.Entity<WcsDeviceAddress>().HasKey(c => c.Id);
            modelBuilder.Entity<WcsDeviceAddress>().Property(c => c.Id).HasColumnName("ID");
            
            modelBuilder.Entity<WcsErrorConfig>().HasKey(c => c.ErrorID);
            modelBuilder.Entity<WcsErrorConfig>().Property(c => c.ErrorID).HasColumnName("ErrorID");
            
            modelBuilder.Entity<WcsPose>().HasKey(c => c.WcName);
            modelBuilder.Entity<WcsPose>().Property(c => c.WcName).HasColumnName("wcName");
            
            modelBuilder.Entity<WcsSRMBuffer>().HasKey(c => c.Id);
            modelBuilder.Entity<WcsSRMBuffer>().Property(c => c.Id).HasColumnName("ID");
            
            modelBuilder.Entity<WcsSRMLast>().HasKey(c => c.RoadWay);
            modelBuilder.Entity<WcsSRMLast>().Property(c => c.RoadWay).HasColumnName("RoadWay");
            
            modelBuilder.Entity<WcsTask>().HasKey(c => c.Id);
            modelBuilder.Entity<WcsTask>().Property(c => c.Id).HasColumnName("id");
            
            modelBuilder.Entity<WcsTaskHis>().HasKey(c => c.Id);
            modelBuilder.Entity<WcsTaskHis>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<OrderAlert>().HasKey(c => c.Id);
            modelBuilder.Entity<OrderAlert>().Property(c => c.Id).HasColumnName("Id");

            modelBuilder.Entity<SysCount>().HasKey(c => c.Type);
            modelBuilder.Entity<SysCount>().Property(c => c.Type).HasColumnName("Type");

            modelBuilder.Entity<MachineWarecell>().HasKey(c => c.Id);
            modelBuilder.Entity<MachineWarecell>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<InventoryAlert>().HasKey(c => c.Id);
            modelBuilder.Entity<InventoryAlert>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<TaskAlert>().HasKey(c => c.Id);
            modelBuilder.Entity<TaskAlert>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<Cycle>().HasKey(c => c.Id);
            modelBuilder.Entity<Cycle>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<StoreStation>().HasKey(c => c.Id);
            modelBuilder.Entity<StoreStation>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<WebStart>().HasKey(c => c.Id);
            modelBuilder.Entity<WebStart>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<LocationDistribution>().HasKey(c => c.Id);
            modelBuilder.Entity<LocationDistribution>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<InterfaceLog>().HasKey(c => c.Id);
            modelBuilder.Entity<InterfaceLog>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<InterfaceLog_Old>().HasKey(c => c.Id);
            modelBuilder.Entity<InterfaceLog_Old>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<ApiInterfaceLog>().HasKey(c => c.Id);
            modelBuilder.Entity<ApiInterfaceLog>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<ApiInterfaceLog_Old>().HasKey(c => c.Id);
            modelBuilder.Entity<ApiInterfaceLog_Old>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<InventoryOut>().HasKey(c => c.Id);
            modelBuilder.Entity<InventoryOut>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<ApiShipmentHeader>().HasKey(c => c.Id);
            modelBuilder.Entity<ApiShipmentHeader>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<ApiShipmentHeaderHistory>().HasKey(c => c.Id);
            modelBuilder.Entity<ApiShipmentHeaderHistory>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<ApiShipmentDetail>().HasKey(c => c.Id);
            modelBuilder.Entity<ApiShipmentDetail>().Property(c => c.Id).HasColumnName("id");

            modelBuilder.Entity<ApiShipmentDetailHistory>().HasKey(c => c.Id);
            modelBuilder.Entity<ApiShipmentDetailHistory>().Property(c => c.Id).HasColumnName("id");
        }
    }
}