TenantDm.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using Microsoft.EntityFrameworkCore;
  2. using Quadarax.Application.QLiberace.Common.Entities.Base.DaoMapper;
  3. namespace Quadarax.Application.QLiberace.Base.Entities.DaoMapper
  4. {
  5. public class TenantDm : TrackedDm<Tenant>
  6. {
  7. public override void Map(ModelBuilder builder)
  8. {
  9. if (builder == null) throw new ArgumentNullException(nameof(builder));
  10. base.Map(builder);
  11. builder.Entity<Tenant>(entity =>
  12. {
  13. entity.ToTable(Constants.Modules.Base.TblTenant, Constants.Modules.Base.Schema);
  14. // indexes
  15. entity.HasIndex(e => e.Code, "IDX_TENANT_CODE")
  16. .IsUnique();
  17. // columns
  18. entity.Property(e => e.Code).IsRequired()
  19. .HasMaxLength(20)
  20. .HasComment("Tenant code. Main key to search.");
  21. entity.Property(e => e.Name).IsRequired()
  22. .HasMaxLength(200)
  23. .HasComment("Tenant name. Informational value.");
  24. entity.Property(e => e.IsLocked).IsRequired()
  25. .HasDefaultValueSql("0")
  26. .HasComment("Flag if tenant locked (not accessible)");
  27. entity.Property(e => e.LastAccess)
  28. .HasColumnType("datetime")
  29. .HasComment("Last access (usage) timestamp.");
  30. }
  31. );
  32. }
  33. }
  34. }