using System; using System.Collections.Generic; using Biskilog_Accounting.Shared.ClientContractModels; using Microsoft.EntityFrameworkCore; namespace Biskilog_Accounting.Server; /// /// This is the main EF DbContext for the Biskilog Accounting /// public partial class BiskilogContext : DbContext { public BiskilogContext() { } public BiskilogContext(DbContextOptions options) : base(options) { } public virtual DbSet Authtypes { get; set; } public virtual DbSet Clientbusinesses { get; set; } public virtual DbSet Clientinfos { get; set; } public virtual DbSet Contracts { get; set; } public virtual DbSet Databasemaps { get; set; } public virtual DbSet Siteaccesspermissions { get; set; } public virtual DbSet Userauths { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PRIMARY"); entity .ToTable("authtypes") .HasCharSet("utf8") .UseCollation("utf8_general_ci"); entity.Property(e => e.Id) .HasColumnType("int(11)") .HasColumnName("id"); entity.Property(e => e.Type) .HasMaxLength(50) .HasColumnName("type") .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); }); modelBuilder.Entity(entity => { entity.HasKey(e => new { e.BusinessId, e.ClientId }) .HasName("PRIMARY") .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); entity .ToTable("clientbusiness") .HasCharSet("utf8") .UseCollation("utf8_general_ci"); entity.Property(e => e.BusinessId) .HasComment("there could be multiple branches of the same business") .HasColumnType("int(11)") .HasColumnName("businessId"); entity.Property(e => e.ClientId) .HasColumnType("int(11)") .HasColumnName("clientID"); entity.Property(e => e.BiskilogVersion) .HasMaxLength(50) .HasDefaultValueSql("''") .HasColumnName("biskilog_version") .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); entity.Property(e => e.BusinessName) .HasMaxLength(50) .HasDefaultValueSql("''") .HasColumnName("business_name") .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); entity.Property(e => e.DateJoined) .HasDefaultValueSql("current_timestamp()") .HasColumnType("datetime") .HasColumnName("date_joined"); entity.Property(e => e.BusinessExternalId) .HasMaxLength(50) .HasDefaultValueSql("''") .HasColumnName("businessExternalId") .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.ClientId).HasName("PRIMARY"); entity .ToTable("clientinfo") .HasCharSet("utf8") .UseCollation("utf8_general_ci"); entity.Property(e => e.ClientId) .HasColumnType("int(11)") .HasColumnName("clientID"); entity.Property(e => e.Email) .HasMaxLength(200) .HasColumnName("email") .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); entity.Property(e => e.Fullname) .HasMaxLength(200) .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); entity.Property(e => e.PhoneNumber) .HasMaxLength(200) .HasColumnName("phoneNumber") .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.ContractId).HasName("PRIMARY"); entity .ToTable("contracts") .HasCharSet("utf8") .UseCollation("utf8_general_ci"); entity.HasIndex(e => new { e.ClientId, e.BusinessId }, "clientId_businessId").IsUnique(); entity.Property(e => e.ContractId) .HasColumnType("int(11)") .HasColumnName("contractId"); entity.Property(e => e.Bill) .HasPrecision(18, 2) .HasColumnName("bill"); entity.Property(e => e.BusinessId) .HasColumnType("int(11)") .HasColumnName("businessId"); entity.Property(e => e.ClientId) .HasColumnType("int(11)") .HasColumnName("clientId"); entity.Property(e => e.Comments) .HasColumnType("text") .HasColumnName("comments") .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); entity.Property(e => e.EndDate) .HasColumnType("datetime") .HasColumnName("end_date"); entity.Property(e => e.StartDate) .HasColumnType("datetime") .HasColumnName("start_date"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.DbNo).HasName("PRIMARY"); entity .ToTable("databasemap") .HasCharSet("utf8") .UseCollation("utf8_general_ci"); entity.HasIndex(e => e.ClientId, "businessId").IsUnique(); entity.Property(e => e.DbNo) .HasColumnType("int(11)") .HasColumnName("db_no"); entity.Property(e => e.ClientId) .HasColumnType("int(11)") .HasColumnName("clientID"); entity.Property(e => e.DbName) .HasMaxLength(50) .HasDefaultValueSql("''") .HasColumnName("db_name") .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); entity.Property(e => e.Domain) .HasMaxLength(50) .HasDefaultValueSql("''") .HasColumnName("domain") .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); entity.Property(e => e.LastSyncDate) .HasColumnType("datetime") .HasColumnName("last_sync_date"); }); modelBuilder.Entity(entity => { entity.HasKey(e => new { e.UserId, e.BusinessId, e.ClientId }) .HasName("PRIMARY") .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0, 0 }); entity .ToTable("siteaccesspermission") .HasCharSet("utf8") .UseCollation("utf8_general_ci"); entity.Property(e => e.UserId) .HasColumnType("int(11)") .HasColumnName("userID"); entity.Property(e => e.BusinessId) .HasComment("businessIds could also been seen as branchID") .HasColumnType("int(11)") .HasColumnName("businessId"); entity.Property(e => e.ClientId) .HasColumnType("int(11)") .HasColumnName("clientId"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.UserId).HasName("PRIMARY"); entity .ToTable("userauth") .HasCharSet("utf8") .UseCollation("utf8_general_ci"); entity.HasIndex(e => e.AuthType, "authType"); entity.HasIndex(e => new { e.ClientId, e.Username, e.Email }, "clientId_username_email").IsUnique(); entity.Property(e => e.UserId) .HasColumnType("int(11)") .HasColumnName("userId"); entity.Property(e => e.AuthType) .HasColumnType("int(11)") .HasColumnName("authType"); entity.Property(e => e.ClientId) .HasColumnType("int(11)") .HasColumnName("clientId"); entity.Property(e => e.Email) .HasMaxLength(200) .HasColumnName("email") .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); entity.Property(e => e.Isactive) .HasColumnType("bit(1)") .HasColumnName("isactive"); entity.Property(e => e.Isowner) .HasColumnType("bit(1)") .HasColumnName("isowner"); entity.Property(e => e.LastLogin) .HasColumnType("datetime") .HasColumnName("last_login"); entity.Property(e => e.Passsword) .HasMaxLength(200) .HasColumnName("passsword") .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); entity.Property(e => e.PhoneNumber) .HasMaxLength(50) .HasColumnName("phoneNumber") .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); entity.Property(e => e.Username) .HasMaxLength(30) .HasColumnName("username") .UseCollation("utf8mb4_general_ci") .HasCharSet("utf8mb4"); }); OnModelCreatingPartial(modelBuilder); } partial void OnModelCreatingPartial(ModelBuilder modelBuilder); }