using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; namespace Workbench.Entity { public partial class QLiberaceContext : DbContext { public QLiberaceContext() { } public QLiberaceContext(DbContextOptions options) : base(options) { } public virtual DbSet Contacts { get; set; } = null!; public virtual DbSet Countries { get; set; } = null!; public virtual DbSet Currencies { get; set; } = null!; public virtual DbSet Customers { get; set; } = null!; public virtual DbSet CustomerUsers { get; set; } = null!; public virtual DbSet QueueData { get; set; } = null!; public virtual DbSet QueueDones { get; set; } = null!; public virtual DbSet QueueFaileds { get; set; } = null!; public virtual DbSet QueuePendings { get; set; } = null!; public virtual DbSet QueueProcessings { get; set; } = null!; public virtual DbSet Settings { get; set; } = null!; public virtual DbSet StatusHistories { get; set; } = null!; public virtual DbSet Tenants { get; set; } = null!; public virtual DbSet TenantCountries { get; set; } = null!; public virtual DbSet TenantCurrencies { get; set; } = null!; public virtual DbSet TenantUsers { get; set; } = null!; public virtual DbSet Users { get; set; } = null!; 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. 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=(localdb)\\MSSQLLocalDB;Database=QLiberace;Trusted_Connection=True;"); } } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(entity => { entity.ToTable("Contact", "Customer"); entity.Property(e => e.Id).HasComment("Contact primary key"); entity.Property(e => e.Address) .HasMaxLength(100) .HasComment("Main address value. If phone, email, sms stores email address or telephone number."); entity.Property(e => e.Address1) .HasMaxLength(100) .HasComment("Secondary address value."); entity.Property(e => e.Caption) .HasMaxLength(100) .HasComment("Contact heading caption."); entity.Property(e => e.City) .HasMaxLength(50) .HasComment("Contact city."); entity.Property(e => e.CountryCode) .HasMaxLength(5) .HasComment("Contact country code."); entity.Property(e => e.Created) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record created timestamp"); entity.Property(e => e.CustomerId).HasComment("Reference to customer that contact belongs"); entity.Property(e => e.IsPreffered).HasComment("Flag if Contact is preffered."); entity.Property(e => e.Modified) .HasColumnType("datetime") .HasComment("Record modified timestamp"); entity.Property(e => e.Modifier) .HasMaxLength(100) .HasComment("Record modifier signature"); entity.Property(e => e.TenantCode) .HasMaxLength(20) .HasComment("Reference to tenant code that contact belongs"); entity.Property(e => e.Type).HasComment("Contact type (0-Email, 1-Address, 2-Phone, 3-SMS)"); entity.Property(e => e.Zip) .HasMaxLength(20) .HasColumnName("ZIP") .HasComment("Contact ZIP code."); entity.HasOne(d => d.Customer) .WithMany(p => p.Contacts) .HasForeignKey(d => d.CustomerId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_CONTACT_CUSTOMER_ID"); }); modelBuilder.Entity(entity => { entity.ToTable("Country", "base"); entity.HasIndex(e => e.Code, "IDX_COUNTRY_CODE") .IsUnique(); entity.Property(e => e.Id).HasComment("Country primary key"); entity.Property(e => e.Code) .HasMaxLength(5) .HasComment("Country code. Main key to search."); entity.Property(e => e.Created) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record created timestamp"); entity.Property(e => e.DefaultCurrencyId).HasComment("Default country currency"); entity.Property(e => e.Modified) .HasColumnType("datetime") .HasComment("Record modified timestamp"); entity.Property(e => e.Modifier) .HasMaxLength(100) .HasComment("Record modifier signature"); entity.Property(e => e.Name) .HasMaxLength(50) .HasComment("Country name. Informational value."); entity.Property(e => e.Vat) .HasColumnName("VAT") .HasComment("Percentage VAT definition"); entity.HasOne(d => d.DefaultCurrency) .WithMany(p => p.Countries) .HasForeignKey(d => d.DefaultCurrencyId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_COUNTRY_CURRENCY_ID"); }); modelBuilder.Entity(entity => { entity.ToTable("Currency", "base"); entity.HasIndex(e => e.Code, "IDX_CURRENCY_ID") .IsUnique(); entity.Property(e => e.Id).HasComment("Currency primary key"); entity.Property(e => e.Code) .HasMaxLength(5) .HasComment("Currency code. Main key to search."); entity.Property(e => e.Created) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record created timestamp"); entity.Property(e => e.Modified) .HasColumnType("datetime") .HasComment("Record modified timestamp"); entity.Property(e => e.Modifier) .HasMaxLength(100) .HasComment("Record modifier signature"); entity.Property(e => e.Name) .HasMaxLength(50) .HasComment("Currency name. Informational value."); entity.Property(e => e.Sign) .HasMaxLength(3) .HasComment("Currency sign chars"); }); modelBuilder.Entity(entity => { entity.ToTable("Customer", "Customer"); entity.HasIndex(e => e.Code, "IDX_CUSTOMER_CODE") .IsUnique(); entity.Property(e => e.Id).HasComment("Setting primary key"); entity.Property(e => e.Code) .HasMaxLength(20) .HasComment("Customer code. Main key to search."); entity.Property(e => e.Created) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record created timestamp"); entity.Property(e => e.Modified) .HasColumnType("datetime") .HasComment("Record modified timestamp"); entity.Property(e => e.Modifier) .HasMaxLength(100) .HasComment("Record modifier signature"); entity.Property(e => e.Name) .HasMaxLength(100) .HasComment("Customer head name. For identification usage."); entity.Property(e => e.TaxCountryCode) .HasMaxLength(5) .HasComment("Tax country region code"); entity.Property(e => e.TaxNumber) .HasMaxLength(20) .HasComment("Customer tax number (business identifier)"); entity.Property(e => e.TenantCode) .HasMaxLength(20) .HasComment("Reference to tenant code that customer belongs"); entity.Property(e => e.VatIncluded) .IsRequired() .HasDefaultValueSql("((1))") .HasComment("Flag if VAT calculation is allowed"); entity.Property(e => e.VatNumber) .HasMaxLength(20) .HasComment("Customer VAT number (VAT identification)"); }); modelBuilder.Entity(entity => { entity.HasNoKey(); entity.ToTable("CustomerUser", "Customer"); entity.Property(e => e.CustomerId).HasComment("Reference to customer"); entity.Property(e => e.UserLoginName) .HasMaxLength(100) .HasComment("Reference to user"); entity.HasOne(d => d.Customer) .WithMany() .HasForeignKey(d => d.CustomerId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_CUSTOMETUSER_CUSTOMER_ID"); }); modelBuilder.Entity(entity => { entity.ToTable("QueueData", "Processor"); entity.Property(e => e.Id).HasComment("Record identifier. Primary key"); entity.Property(e => e.Code) .HasMaxLength(100) .HasComment("Data code. Main key to search."); entity.Property(e => e.IsInput).HasComment("Defines if data is input value"); entity.Property(e => e.ParentId).HasComment("Reference to master (or group) record"); entity.Property(e => e.SequenceNo).HasComment("Ordinal sequence number of processing related records"); entity.Property(e => e.Value) .HasMaxLength(500) .HasComment("Data value"); entity.Property(e => e.ValueTypeQualified) .HasMaxLength(500) .HasComment("Qualified name of value type"); entity.HasOne(d => d.Parent) .WithMany(p => p.InverseParent) .HasForeignKey(d => d.ParentId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_DATA_DATA_ID"); }); modelBuilder.Entity(entity => { entity.ToTable("QueueDone", "Processor"); entity.Property(e => e.Id).HasComment("Record identifier. Primary key"); entity.Property(e => e.AffinityWorker) .HasMaxLength(64) .HasComment("Owner worker identifier who processing task"); entity.Property(e => e.Attempt).HasComment("Attempt counter to process task"); entity.Property(e => e.Created) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record created timestamp"); entity.Property(e => e.DataId).HasComment("Reference to data collection"); entity.Property(e => e.Finished) .HasColumnType("datetime") .HasComment("Record finished at"); entity.Property(e => e.LastStatusChanged) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Last status change timestamp"); entity.Property(e => e.Owner) .HasMaxLength(50) .HasComment("Owner (abstract) key identifier. Usually entity code"); entity.Property(e => e.StartFrom) .HasColumnType("datetime") .HasComment("Record processing from datetime"); entity.Property(e => e.StartTo) .HasColumnType("datetime") .HasComment("Record processing to datetime. If overflow then record is expired."); entity.Property(e => e.Started) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record started processing at"); entity.Property(e => e.Status).HasComment("Record status (Pending-0,Assigned-1,Working-2,Success-3,Failed-4,Expired-5)"); entity.Property(e => e.StatusHistoryId).HasComment("Reference to status history collection"); entity.Property(e => e.TenantCode) .HasMaxLength(20) .HasComment("Reference to tenant code that queue belongs"); entity.HasOne(d => d.Data) .WithMany(p => p.QueueDones) .HasForeignKey(d => d.DataId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_QDONE_DATA_ID"); entity.HasOne(d => d.StatusHistory) .WithMany(p => p.QueueDones) .HasForeignKey(d => d.StatusHistoryId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_QDONE_STATUSHISTORY_ID"); }); modelBuilder.Entity(entity => { entity.ToTable("QueueFailed", "Processor"); entity.Property(e => e.Id).HasComment("Record identifier. Primary key"); entity.Property(e => e.AffinityWorker) .HasMaxLength(64) .HasComment("Owner worker identifier who processing task"); entity.Property(e => e.Attempt).HasComment("Attempt counter to process task"); entity.Property(e => e.Created) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record created timestamp"); entity.Property(e => e.DataId).HasComment("Reference to data collection"); entity.Property(e => e.Finished) .HasColumnType("datetime") .HasComment("Record finished at"); entity.Property(e => e.LastStatusChanged) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Last status change timestamp"); entity.Property(e => e.Owner) .HasMaxLength(50) .HasComment("Owner (abstract) key identifier. Usually entity code"); entity.Property(e => e.StartFrom) .HasColumnType("datetime") .HasComment("Record processing from datetime"); entity.Property(e => e.StartTo) .HasColumnType("datetime") .HasComment("Record processing to datetime. If overflow then record is expired."); entity.Property(e => e.Started) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record started processing at"); entity.Property(e => e.Status).HasComment("Record status (Pending-0,Assigned-1,Working-2,Success-3,Failed-4,Expired-5)"); entity.Property(e => e.StatusHistoryId).HasComment("Reference to status history collection"); entity.Property(e => e.TenantCode) .HasMaxLength(20) .HasComment("Reference to tenant code that queue belongs"); entity.HasOne(d => d.Data) .WithMany(p => p.QueueFaileds) .HasForeignKey(d => d.DataId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_QFAILED_DATA_ID"); entity.HasOne(d => d.StatusHistory) .WithMany(p => p.QueueFaileds) .HasForeignKey(d => d.StatusHistoryId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_QFAILED_STATUSHISTORY_ID"); }); modelBuilder.Entity(entity => { entity.ToTable("QueuePending", "Processor"); entity.Property(e => e.Id).HasComment("Record identifier. Primary key"); entity.Property(e => e.AffinityWorker) .HasMaxLength(64) .HasComment("Owner worker identifier who processing task"); entity.Property(e => e.Created) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record created timestamp"); entity.Property(e => e.DataId).HasComment("Reference to data collection"); entity.Property(e => e.LastStatusChanged) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Last status change timestamp"); entity.Property(e => e.Owner) .HasMaxLength(50) .HasComment("Owner (abstract) key identifier. Usually entity code"); entity.Property(e => e.StartFrom) .HasColumnType("datetime") .HasComment("Record processing from datetime"); entity.Property(e => e.StartTo) .HasColumnType("datetime") .HasComment("Record processing to datetime. If overflow then record is expired."); entity.Property(e => e.Status).HasComment("Record status (Pending-0,Assigned-1,Working-2,Success-3,Failed-4,Expired-5)"); entity.Property(e => e.StatusHistoryId).HasComment("Reference to status history collection"); entity.Property(e => e.TenantCode) .HasMaxLength(20) .HasComment("Reference to tenant code that queue belongs"); entity.HasOne(d => d.Data) .WithMany(p => p.QueuePendings) .HasForeignKey(d => d.DataId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_QPENDING_DATA_ID"); entity.HasOne(d => d.StatusHistory) .WithMany(p => p.QueuePendings) .HasForeignKey(d => d.StatusHistoryId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_QPENDING_STATUSHISTORY_ID"); }); modelBuilder.Entity(entity => { entity.ToTable("QueueProcessing", "Processor"); entity.Property(e => e.Id).HasComment("Record identifier. Primary key"); entity.Property(e => e.AffinityWorker) .HasMaxLength(64) .HasComment("Owner worker identifier who processing task"); entity.Property(e => e.Attempt).HasComment("Attempt counter to process task"); entity.Property(e => e.Created) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record created timestamp"); entity.Property(e => e.DataId).HasComment("Reference to data collection"); entity.Property(e => e.Finished) .HasColumnType("datetime") .HasComment("Record finished at"); entity.Property(e => e.LastStatusChanged) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Last status change timestamp"); entity.Property(e => e.Owner) .HasMaxLength(50) .HasComment("Owner (abstract) key identifier. Usually entity code"); entity.Property(e => e.StartFrom) .HasColumnType("datetime") .HasComment("Record processing from datetime"); entity.Property(e => e.StartTo) .HasColumnType("datetime") .HasComment("Record processing to datetime. If overflow then record is expired."); entity.Property(e => e.Started) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record started processing at"); entity.Property(e => e.Status).HasComment("Record status (Pending-0,Assigned-1,Working-2,Success-3,Failed-4,Expired-5)"); entity.Property(e => e.StatusHistoryId).HasComment("Reference to status history collection"); entity.Property(e => e.TenantCode) .HasMaxLength(20) .HasComment("Reference to tenant code that queue belongs"); entity.HasOne(d => d.Data) .WithMany(p => p.QueueProcessings) .HasForeignKey(d => d.DataId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_QPROCESSING_DATA_ID"); entity.HasOne(d => d.StatusHistory) .WithMany(p => p.QueueProcessings) .HasForeignKey(d => d.StatusHistoryId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_QPROCESSING_STATUSHISTORY_ID"); }); modelBuilder.Entity(entity => { entity.ToTable("Setting", "base"); entity.HasIndex(e => new { e.TenantId, e.ModuleCode, e.Code }, "IDX_SETTING_TENANT_MCODE_CODE") .IsUnique(); entity.Property(e => e.Id).HasComment("Setting primary key"); entity.Property(e => e.Code) .HasMaxLength(100) .HasComment("Setting code. Main key to search."); entity.Property(e => e.Created) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record created timestamp"); entity.Property(e => e.Description) .HasMaxLength(500) .HasComment("Setting value description"); entity.Property(e => e.IsEnabled).HasComment("Flag if setting is enabled"); entity.Property(e => e.Modified) .HasColumnType("datetime") .HasComment("Record modified timestamp"); entity.Property(e => e.Modifier) .HasMaxLength(100) .HasComment("Record modifier signature"); entity.Property(e => e.ModuleCode) .HasMaxLength(10) .HasComment("Module code that setting belongs. Secondary key"); entity.Property(e => e.ParentId).HasComment("Reference to parent setting"); entity.Property(e => e.SequenceNo).HasComment("Order number"); entity.Property(e => e.TenantId).HasComment("Reference to tenant that setting belongs"); entity.Property(e => e.Value).HasComment("Setting value"); entity.Property(e => e.ValueTypeQualified) .HasMaxLength(500) .HasComment("Qualified name of value type"); entity.HasOne(d => d.Parent) .WithMany(p => p.InverseParent) .HasForeignKey(d => d.ParentId) .HasConstraintName("REL_SETTING_SETTING_ID"); entity.HasOne(d => d.Tenant) .WithMany(p => p.Settings) .HasForeignKey(d => d.TenantId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_SETTING_TENANT_ID"); }); modelBuilder.Entity(entity => { entity.ToTable("StatusHistory", "Processor"); entity.Property(e => e.Id).HasComment("Record identifier. Primary key"); entity.Property(e => e.Attempt) .HasDefaultValueSql("((0))") .HasComment("Actual attempt counter to process task"); entity.Property(e => e.Created) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record created timestamp"); entity.Property(e => e.ErrorMessage).HasComment("Last error message"); entity.Property(e => e.ParentId).HasComment("Reference to master (or group) record"); entity.Property(e => e.Status).HasComment("Record status (Pending-0,Assigned-1,Working-2,Success-3,Failed-4,Expired-5)"); entity.HasOne(d => d.Parent) .WithMany(p => p.InverseParent) .HasForeignKey(d => d.ParentId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_STATUSHISTORY_STATUSHISTORY_ID"); }); modelBuilder.Entity(entity => { entity.ToTable("Tenant", "base"); entity.HasIndex(e => e.Code, "IDX_TENANT_CODE") .IsUnique(); entity.Property(e => e.Id).HasComment("Tenant primary key"); entity.Property(e => e.Code) .HasMaxLength(20) .HasComment("Tenant code. Main key to search."); entity.Property(e => e.Created) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record created timestamp"); entity.Property(e => e.IsLocked).HasComment("Flag if tenant locked (not accessable)"); entity.Property(e => e.LastAccess) .HasColumnType("datetime") .HasComment("Last access (usage) timestamp."); entity.Property(e => e.Modified) .HasColumnType("datetime") .HasComment("Record modified timestamp"); entity.Property(e => e.Modifier) .HasMaxLength(100) .HasComment("Record modifier signature"); entity.Property(e => e.Name) .HasMaxLength(200) .HasComment("Tenant name. Informational value."); }); modelBuilder.Entity(entity => { entity.HasNoKey(); entity.ToTable("TenantCountry", "base"); entity.Property(e => e.CountryId).HasComment("Reference to country"); entity.Property(e => e.TenantId).HasComment("Reference to tenant"); entity.HasOne(d => d.Country) .WithMany() .HasForeignKey(d => d.CountryId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_TENANTCOUNTRY_COUNTRY_ID"); entity.HasOne(d => d.Tenant) .WithMany() .HasForeignKey(d => d.TenantId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_TENANTCOUNTRY_TENANT_ID"); }); modelBuilder.Entity(entity => { entity.HasNoKey(); entity.ToTable("TenantCurrency", "base"); entity.Property(e => e.CurrencyId).HasComment("Reference to currency"); entity.Property(e => e.TenantId).HasComment("Reference to tenant"); entity.HasOne(d => d.Currency) .WithMany() .HasForeignKey(d => d.CurrencyId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_TENANTCURRENCY_CURRENCY__ID"); entity.HasOne(d => d.Tenant) .WithMany() .HasForeignKey(d => d.TenantId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_TENANTCURRENCT_TENANT_ID"); }); modelBuilder.Entity(entity => { entity.HasNoKey(); entity.ToTable("TenantUser", "base"); entity.Property(e => e.TenantId).HasComment("Reference to tenant"); entity.Property(e => e.UserId).HasComment("Reference to user"); entity.HasOne(d => d.Tenant) .WithMany() .HasForeignKey(d => d.TenantId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_TENANTUSER_TENANT_ID"); entity.HasOne(d => d.User) .WithMany() .HasForeignKey(d => d.UserId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("REL_TENANTUSER_USER_ID"); }); modelBuilder.Entity(entity => { entity.ToTable("User", "base"); entity.HasIndex(e => e.LoginName, "IDX_USER_LOGINNAME") .IsUnique(); entity.Property(e => e.Id).HasComment("User primary key"); entity.Property(e => e.Created) .HasColumnType("datetime") .HasDefaultValueSql("(getdate())") .HasComment("Record created timestamp"); entity.Property(e => e.IsLocked).HasComment("Flag if user access locked (not accessable)"); entity.Property(e => e.LoginName) .HasMaxLength(100) .HasComment("User login name name. Key search value"); entity.Property(e => e.Modified) .HasColumnType("datetime") .HasComment("Record modified timestamp"); entity.Property(e => e.Modifier) .HasMaxLength(100) .HasComment("Record modifier signature"); }); OnModelCreatingPartial(modelBuilder); } partial void OnModelCreatingPartial(ModelBuilder modelBuilder); } }