using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
// If you have enabled NRTs for your project, then un-comment the following line:
// #nullable disable

namespace MS.WebApi.stockdbModels
{
    public partial class stockdbContext : DbContext
    {
        public stockdbContext()
        {
        }

        public stockdbContext(DbContextOptions<stockdbContext> options)
            : base(options)
        {
        }

        public virtual DbSet<IBatchRecords> IBatchRecords { get; set; }
        public virtual DbSet<IFactories> IFactories { get; set; }
        public virtual DbSet<IProductCategories> IProductCategories { get; set; }
        public virtual DbSet<IProductUnits> IProductUnits { get; set; }
        public virtual DbSet<IProducts> IProducts { get; set; }
        public virtual DbSet<IProductshelfRecords> IProductshelfRecords { get; set; }
        public virtual DbSet<ISites> ISites { get; set; }
        public virtual DbSet<IStockcountRecords> IStockcountRecords { get; set; }
        public virtual DbSet<IStockcountproductRecords> IStockcountproductRecords { get; set; }
        public virtual DbSet<ISuppliers> ISuppliers { get; set; }
        public virtual DbSet<IUsers> IUsers { get; set; }
        public virtual DbSet<IWarehouseRecords> IWarehouseRecords { get; set; }
        public virtual DbSet<IWarehouses> IWarehouses { get; set; }
        public virtual DbSet<Inventoryefmigrationshistory> Inventoryefmigrationshistory { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
                optionsBuilder.UseMySql("server=47.97.120.160;user=root;database=stockdb;port=3307;password=Wayne@123;sslmode=None", x => x.ServerVersion("8.0.22-mysql"));
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<IBatchRecords>(entity =>
            {
                entity.ToTable("i_batch_records");

                entity.HasIndex(e => e.RefBatchId);

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.AllocatedToBuId)
                    .HasColumnName("allocated_to_buId")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.BatchStatus).HasColumnName("batch_status");

                entity.Property(e => e.BatchSubType).HasColumnName("batch_sub_type");

                entity.Property(e => e.BatchType).HasColumnName("batch_type");

                entity.Property(e => e.Created)
                    .HasColumnName("created")
                    .HasColumnType("datetime");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("datetime");

                entity.Property(e => e.DeviceSn)
                    .HasColumnName("device_sn")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Finished).HasColumnName("finished");

                entity.Property(e => e.IsDeleted).HasColumnName("is_deleted");

                entity.Property(e => e.Modified)
                    .HasColumnName("modified")
                    .HasColumnType("datetime");

                entity.Property(e => e.Note)
                    .HasColumnName("note")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.OperatorUserId)
                    .HasColumnName("operator_user_id")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.RefBatchId).HasColumnName("ref_batch_id");

                entity.Property(e => e.SiteId).HasColumnName("site_id");

                entity.Property(e => e.TotalAmount)
                    .HasColumnName("total_amount")
                    .HasColumnType("decimal(65,30)");

                entity.Property(e => e.Uid)
                    .HasColumnName("uid")
                    .HasColumnType("varchar(36)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Version).HasColumnName("version");

                entity.HasOne(d => d.RefBatch)
                    .WithMany(p => p.InverseRefBatch)
                    .HasForeignKey(d => d.RefBatchId);
            });

            modelBuilder.Entity<IFactories>(entity =>
            {
                entity.ToTable("i_factories");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Address)
                    .HasColumnName("address")
                    .HasColumnType("varchar(200)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Config)
                    .HasColumnName("config")
                    .HasColumnType("text")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Contact)
                    .HasColumnName("contact")
                    .HasColumnType("varchar(50)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Created)
                    .HasColumnName("created")
                    .HasColumnType("datetime");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("datetime");

                entity.Property(e => e.IsDeleted).HasColumnName("is_deleted");

                entity.Property(e => e.Modified)
                    .HasColumnName("modified")
                    .HasColumnType("datetime");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(100)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.SiteId).HasColumnName("site_id");

                entity.Property(e => e.Uid)
                    .HasColumnName("uid")
                    .HasColumnType("varchar(36)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Version).HasColumnName("version");
            });

            modelBuilder.Entity<IProductCategories>(entity =>
            {
                entity.ToTable("i_product_categories");

                entity.HasIndex(e => e.ParentId);

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.AllowIn).HasColumnName("allow_in");

                entity.Property(e => e.AllowOut).HasColumnName("allow_out");

                entity.Property(e => e.Created)
                    .HasColumnName("created")
                    .HasColumnType("datetime");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("datetime");

                entity.Property(e => e.IsDeleted).HasColumnName("is_deleted");

                entity.Property(e => e.Modified)
                    .HasColumnName("modified")
                    .HasColumnType("datetime");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(100)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.ParentId).HasColumnName("parent_id");

                entity.Property(e => e.SiteId).HasColumnName("site_id");

                entity.Property(e => e.Uid)
                    .HasColumnName("uid")
                    .HasColumnType("varchar(36)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Version).HasColumnName("version");

                entity.Property(e => e.Weight).HasColumnName("weight");

                entity.HasOne(d => d.Parent)
                    .WithMany(p => p.InverseParent)
                    .HasForeignKey(d => d.ParentId);
            });

            modelBuilder.Entity<IProductUnits>(entity =>
            {
                entity.ToTable("i_product_units");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Created)
                    .HasColumnName("created")
                    .HasColumnType("datetime");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("datetime");

                entity.Property(e => e.IsDeleted).HasColumnName("is_deleted");

                entity.Property(e => e.Modified)
                    .HasColumnName("modified")
                    .HasColumnType("datetime");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(50)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Note)
                    .HasColumnName("note")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.SiteId).HasColumnName("site_id");

                entity.Property(e => e.Uid)
                    .HasColumnName("uid")
                    .HasColumnType("varchar(36)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Version).HasColumnName("version");
            });

            modelBuilder.Entity<IProducts>(entity =>
            {
                entity.ToTable("i_products");

                entity.HasIndex(e => e.Barcode);

                entity.HasIndex(e => e.FactoryId);

                entity.HasIndex(e => e.ParentId);

                entity.HasIndex(e => e.ProductunitId);

                entity.HasIndex(e => e.RefProductId);

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.AllowIn).HasColumnName("allow_in");

                entity.Property(e => e.AllowOut).HasColumnName("allow_out");

                entity.Property(e => e.Barcode)
                    .HasColumnName("barcode")
                    .HasColumnType("varchar(60)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.CategoryId)
                    .HasColumnName("category_id")
                    .HasColumnType("varchar(255)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Created)
                    .HasColumnName("created")
                    .HasColumnType("datetime");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("datetime");

                entity.Property(e => e.FactoryId).HasColumnName("factory_id");

                entity.Property(e => e.Fullname)
                    .HasColumnName("fullname")
                    .HasColumnType("varchar(100)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.IsDeleted).HasColumnName("is_deleted");

                entity.Property(e => e.Modified)
                    .HasColumnName("modified")
                    .HasColumnType("datetime");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(100)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Plu)
                    .HasColumnName("plu")
                    .HasColumnType("varchar(20)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Price)
                    .HasColumnName("price")
                    .HasColumnType("decimal(65,30)");

                entity.Property(e => e.ProductunitId).HasColumnName("productunit_id");

                entity.Property(e => e.RefProductId).HasColumnName("ref_product_id");

                entity.Property(e => e.RpCreateUser)
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.RpCreatedDateTime).HasDefaultValueSql("'0001-01-01 00:00:00.000000'");

                entity.Property(e => e.RpDateToActivate).HasDefaultValueSql("'0001-01-01 00:00:00.000000'");

                entity.Property(e => e.RpDateToDeactivate).HasDefaultValueSql("'0001-01-01 00:00:00.000000'");

                entity.Property(e => e.SiteId).HasColumnName("site_id");

                entity.Property(e => e.Uid)
                    .HasColumnName("uid")
                    .HasColumnType("varchar(36)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Version).HasColumnName("version");

                entity.Property(e => e.Weight).HasColumnType("decimal(65,30)");

                entity.HasOne(d => d.Factory)
                    .WithMany(p => p.IProducts)
                    .HasForeignKey(d => d.FactoryId);

                entity.HasOne(d => d.Parent)
                    .WithMany(p => p.IProducts)
                    .HasForeignKey(d => d.ParentId);

                entity.HasOne(d => d.Productunit)
                    .WithMany(p => p.IProducts)
                    .HasForeignKey(d => d.ProductunitId);

                entity.HasOne(d => d.RefProduct)
                    .WithMany(p => p.InverseRefProduct)
                    .HasForeignKey(d => d.RefProductId);
            });

            modelBuilder.Entity<IProductshelfRecords>(entity =>
            {
                entity.ToTable("i_productshelf_records");

                entity.HasIndex(e => e.ProductId);

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Created)
                    .HasColumnName("created")
                    .HasColumnType("datetime");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("datetime");

                entity.Property(e => e.IsDeleted).HasColumnName("is_deleted");

                entity.Property(e => e.Modified)
                    .HasColumnName("modified")
                    .HasColumnType("datetime");

                entity.Property(e => e.Note)
                    .HasColumnName("note")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.OperatorUserId)
                    .HasColumnName("operator_user_id")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.ProductId).HasColumnName("product_id");

                entity.Property(e => e.SalePrice)
                    .HasColumnName("sale_price")
                    .HasColumnType("decimal(65,30)");

                entity.Property(e => e.SiteId).HasColumnName("site_id");

                entity.Property(e => e.Uid)
                    .HasColumnName("uid")
                    .HasColumnType("varchar(36)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Version).HasColumnName("version");

                entity.HasOne(d => d.Product)
                    .WithMany(p => p.IProductshelfRecords)
                    .HasForeignKey(d => d.ProductId);
            });

            modelBuilder.Entity<ISites>(entity =>
            {
                entity.ToTable("i_sites");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Code)
                    .HasColumnName("code")
                    .HasColumnType("varchar(20)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Created)
                    .HasColumnName("created")
                    .HasColumnType("datetime");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("datetime");

                entity.Property(e => e.Enabled)
                    .HasColumnName("enabled")
                    .HasColumnType("bit(1)");

                entity.Property(e => e.IsDeleted).HasColumnName("is_deleted");

                entity.Property(e => e.Language)
                    .HasColumnName("language")
                    .HasColumnType("varchar(10)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Modified)
                    .HasColumnName("modified")
                    .HasColumnType("datetime");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(100)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Options)
                    .HasColumnName("options")
                    .HasColumnType("text")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.OriginalId)
                    .HasColumnName("original_id")
                    .HasColumnType("varchar(50)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.SiteId).HasColumnName("site_id");

                entity.Property(e => e.Type)
                    .HasColumnName("type")
                    .HasColumnType("varchar(10)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Uid)
                    .HasColumnName("uid")
                    .HasColumnType("varchar(36)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Version).HasColumnName("version");
            });

            modelBuilder.Entity<IStockcountRecords>(entity =>
            {
                entity.ToTable("i_stockcount_records");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Created)
                    .HasColumnName("created")
                    .HasColumnType("datetime");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("datetime");

                entity.Property(e => e.DeviceSn)
                    .HasColumnName("device_sn")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Finished).HasColumnName("finished");

                entity.Property(e => e.IsDeleted).HasColumnName("is_deleted");

                entity.Property(e => e.Modified)
                    .HasColumnName("modified")
                    .HasColumnType("datetime");

                entity.Property(e => e.Note)
                    .HasColumnName("note")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.OperatorUserId)
                    .HasColumnName("operator_user_id")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.SiteId).HasColumnName("site_id");

                entity.Property(e => e.Status).HasColumnName("status");

                entity.Property(e => e.Uid)
                    .HasColumnName("uid")
                    .HasColumnType("varchar(36)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Version).HasColumnName("version");
            });

            modelBuilder.Entity<IStockcountproductRecords>(entity =>
            {
                entity.ToTable("i_stockcountproduct_records");

                entity.HasIndex(e => e.ProductId);

                entity.HasIndex(e => e.StockcountId);

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.ActualStock)
                    .HasColumnName("actual_stock")
                    .HasColumnType("decimal(65,30)");

                entity.Property(e => e.Counted).HasColumnName("counted");

                entity.Property(e => e.Created)
                    .HasColumnName("created")
                    .HasColumnType("datetime");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("datetime");

                entity.Property(e => e.ExpectedStock)
                    .HasColumnName("expected_stock")
                    .HasColumnType("decimal(65,30)");

                entity.Property(e => e.IsDeleted).HasColumnName("is_deleted");

                entity.Property(e => e.Modified)
                    .HasColumnName("modified")
                    .HasColumnType("datetime");

                entity.Property(e => e.Note)
                    .HasColumnName("note")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.ProductId).HasColumnName("product_id");

                entity.Property(e => e.SiteId).HasColumnName("site_id");

                entity.Property(e => e.Status).HasColumnName("status");

                entity.Property(e => e.StockcountId).HasColumnName("stockcount_id");

                entity.Property(e => e.Uid)
                    .HasColumnName("uid")
                    .HasColumnType("varchar(36)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Version).HasColumnName("version");

                entity.HasOne(d => d.Product)
                    .WithMany(p => p.IStockcountproductRecords)
                    .HasForeignKey(d => d.ProductId);

                entity.HasOne(d => d.Stockcount)
                    .WithMany(p => p.IStockcountproductRecords)
                    .HasForeignKey(d => d.StockcountId)
                    .HasConstraintName("FK_i_stockcountproduct_records_i_stockcount_records_stockcount_~");
            });

            modelBuilder.Entity<ISuppliers>(entity =>
            {
                entity.ToTable("i_suppliers");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Address)
                    .HasColumnName("address")
                    .HasColumnType("varchar(200)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.BankAccount)
                    .HasColumnName("bank_account")
                    .HasColumnType("varchar(60)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.BankName)
                    .HasColumnName("bank_name")
                    .HasColumnType("varchar(100)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.CompanyCode)
                    .HasColumnName("company_code")
                    .HasColumnType("varchar(60)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Config)
                    .HasColumnName("config")
                    .HasColumnType("text")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Contact)
                    .HasColumnName("contact")
                    .HasColumnType("varchar(100)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Created)
                    .HasColumnName("created")
                    .HasColumnType("datetime");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("datetime");

                entity.Property(e => e.Email)
                    .HasColumnName("email")
                    .HasColumnType("varchar(100)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.IsDeleted).HasColumnName("is_deleted");

                entity.Property(e => e.Modified)
                    .HasColumnName("modified")
                    .HasColumnType("datetime");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(100)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Phone)
                    .HasColumnName("phone")
                    .HasColumnType("varchar(100)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.SiteId).HasColumnName("site_id");

                entity.Property(e => e.Uid)
                    .HasColumnName("uid")
                    .HasColumnType("varchar(36)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Version).HasColumnName("version");
            });

            modelBuilder.Entity<IUsers>(entity =>
            {
                entity.ToTable("i_users");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Accessed)
                    .HasColumnName("accessed")
                    .HasColumnType("datetime");

                entity.Property(e => e.Created)
                    .HasColumnName("created")
                    .HasColumnType("datetime");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("datetime");

                entity.Property(e => e.Email)
                    .HasColumnName("email")
                    .HasColumnType("varchar(60)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Enabled)
                    .HasColumnName("enabled")
                    .HasColumnType("bit(1)");

                entity.Property(e => e.IsDeleted).HasColumnName("is_deleted");

                entity.Property(e => e.Login)
                    .HasColumnName("login")
                    .HasColumnType("varchar(60)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Modified)
                    .HasColumnName("modified")
                    .HasColumnType("datetime");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(60)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Options)
                    .HasColumnName("options")
                    .HasColumnType("text")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.OriginalId)
                    .HasColumnName("original_id")
                    .HasColumnType("varchar(50)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Password)
                    .HasColumnName("password")
                    .HasColumnType("varchar(60)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Phone)
                    .HasColumnName("phone")
                    .HasColumnType("varchar(20)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.SiteId).HasColumnName("site_id");

                entity.Property(e => e.Uid)
                    .HasColumnName("uid")
                    .HasColumnType("varchar(36)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Version).HasColumnName("version");
            });

            modelBuilder.Entity<IWarehouseRecords>(entity =>
            {
                entity.ToTable("i_warehouse_records");

                entity.HasIndex(e => e.BatchRecordId);

                entity.HasIndex(e => e.ProductId);

                entity.HasIndex(e => e.ReferenceRecordId);

                entity.HasIndex(e => e.SiteId);

                entity.HasIndex(e => e.WarehouseId);

                entity.HasIndex(e => new { e.ProductId, e.Balance });

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Balance)
                    .HasColumnName("balance")
                    .HasColumnType("decimal(65,30)");

                entity.Property(e => e.BatchRecordId).HasColumnName("batch_record_id");

                entity.Property(e => e.Created)
                    .HasColumnName("created")
                    .HasColumnType("datetime");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("datetime");

                entity.Property(e => e.ExpiredDate)
                    .HasColumnName("expired_date")
                    .HasColumnType("datetime");

                entity.Property(e => e.Extfields)
                    .HasColumnName("extfields")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.FreezeStatus).HasColumnName("freeze_status");

                entity.Property(e => e.FreezeType).HasColumnName("freeze_type");

                entity.Property(e => e.IsDeleted).HasColumnName("is_deleted");

                entity.Property(e => e.Modified)
                    .HasColumnName("modified")
                    .HasColumnType("datetime");

                entity.Property(e => e.Note)
                    .HasColumnName("note")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.OutboundType).HasColumnName("outbound_type");

                entity.Property(e => e.Price)
                    .HasColumnName("price")
                    .HasColumnType("decimal(65,30)");

                entity.Property(e => e.ProductId).HasColumnName("product_id");

                entity.Property(e => e.Quantity)
                    .HasColumnName("quantity")
                    .HasColumnType("decimal(65,30)");

                entity.Property(e => e.Reason)
                    .HasColumnName("reason")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.ReferenceRecordId).HasColumnName("reference_record_id");

                entity.Property(e => e.SiteId).HasColumnName("site_id");

                entity.Property(e => e.SourceId)
                    .HasColumnName("source_id")
                    .HasColumnType("longtext")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.TransactionStatus).HasColumnName("transaction_status");

                entity.Property(e => e.TransactionType).HasColumnName("transaction_type");

                entity.Property(e => e.Uid)
                    .HasColumnName("uid")
                    .HasColumnType("varchar(36)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Unbox).HasColumnName("unbox");

                entity.Property(e => e.Version).HasColumnName("version");

                entity.Property(e => e.WarehouseId).HasColumnName("warehouse_id");

                entity.HasOne(d => d.BatchRecord)
                    .WithMany(p => p.IWarehouseRecords)
                    .HasForeignKey(d => d.BatchRecordId);

                entity.HasOne(d => d.Product)
                    .WithMany(p => p.IWarehouseRecords)
                    .HasForeignKey(d => d.ProductId);

                entity.HasOne(d => d.ReferenceRecord)
                    .WithMany(p => p.InverseReferenceRecord)
                    .HasForeignKey(d => d.ReferenceRecordId);

                entity.HasOne(d => d.Warehouse)
                    .WithMany(p => p.IWarehouseRecords)
                    .HasForeignKey(d => d.WarehouseId);
            });

            modelBuilder.Entity<IWarehouses>(entity =>
            {
                entity.ToTable("i_warehouses");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Address)
                    .HasColumnName("address")
                    .HasColumnType("varchar(100)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.AllowIn).HasColumnName("allow_in");

                entity.Property(e => e.AllowOut).HasColumnName("allow_out");

                entity.Property(e => e.Config)
                    .HasColumnName("config")
                    .HasColumnType("text")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Contact)
                    .HasColumnName("contact")
                    .HasColumnType("varchar(50)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Created)
                    .HasColumnName("created")
                    .HasColumnType("datetime");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("datetime");

                entity.Property(e => e.Email)
                    .HasColumnName("email")
                    .HasColumnType("varchar(100)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Enabled).HasColumnName("enabled");

                entity.Property(e => e.IsDeleted).HasColumnName("is_deleted");

                entity.Property(e => e.Modified)
                    .HasColumnName("modified")
                    .HasColumnType("datetime");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(50)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Phone)
                    .HasColumnName("phone")
                    .HasColumnType("varchar(100)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.SiteId).HasColumnName("site_id");

                entity.Property(e => e.Size)
                    .HasColumnName("size")
                    .HasColumnType("varchar(50)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.ThresholdMode)
                    .HasColumnName("threshold_mode")
                    .HasColumnType("varchar(50)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.ThresholdValue)
                    .IsRequired()
                    .HasColumnName("threshold_value")
                    .HasColumnType("varchar(20)")
                    .HasDefaultValueSql("''")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Uid)
                    .HasColumnName("uid")
                    .HasColumnType("varchar(36)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.Version).HasColumnName("version");
            });

            modelBuilder.Entity<Inventoryefmigrationshistory>(entity =>
            {
                entity.HasKey(e => e.MigrationId)
                    .HasName("PRIMARY");

                entity.ToTable("__inventoryefmigrationshistory");

                entity.Property(e => e.MigrationId)
                    .HasColumnType("varchar(95)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");

                entity.Property(e => e.ProductVersion)
                    .IsRequired()
                    .HasColumnType("varchar(32)")
                    .HasCharSet("utf8mb4")
                    .HasCollation("utf8mb4_0900_ai_ci");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
