You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
273 lines
9.7 KiB
273 lines
9.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using Biskilog_Accounting.Shared.ClientContractModels;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Biskilog_Accounting.Server;
|
|
/// <summary>
|
|
/// This is the main EF DbContext for the Biskilog Accounting
|
|
/// </summary>
|
|
public partial class BiskilogContext : DbContext
|
|
{
|
|
public BiskilogContext()
|
|
{
|
|
}
|
|
public BiskilogContext(DbContextOptions<BiskilogContext> options)
|
|
: base(options)
|
|
{
|
|
}
|
|
|
|
public virtual DbSet<Authtype> Authtypes { get; set; }
|
|
|
|
public virtual DbSet<Clientbusiness> Clientbusinesses { get; set; }
|
|
|
|
public virtual DbSet<Clientinfo> Clientinfos { get; set; }
|
|
|
|
public virtual DbSet<Contract> Contracts { get; set; }
|
|
|
|
public virtual DbSet<Databasemap> Databasemaps { get; set; }
|
|
|
|
public virtual DbSet<Siteaccesspermission> Siteaccesspermissions { get; set; }
|
|
|
|
public virtual DbSet<Userauth> Userauths { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder
|
|
.UseCollation("utf8mb4_general_ci")
|
|
.HasCharSet("utf8mb4");
|
|
|
|
modelBuilder.Entity<Authtype>(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<Clientbusiness>(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");
|
|
});
|
|
|
|
modelBuilder.Entity<Clientinfo>(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<Contract>(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<Databasemap>(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<Siteaccesspermission>(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<Userauth>(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);
|
|
}
|
|
|