TenantUserDm.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Quadarax.Application.QLiberace.Common.Entities.Base.DaoMapper;
  2. using Microsoft.EntityFrameworkCore;
  3. namespace Quadarax.Application.QLiberace.Base.Entities.DaoMapper
  4. {
  5. public class TenantUserDm : KeylessDm<TenantUser>
  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<TenantUser>(entity =>
  12. {
  13. entity.ToTable(Constants.Modules.Base.TblTenantUser, Constants.Modules.Base.Schema);
  14. // foreign keys
  15. entity.Property(e => e.TenantId).IsRequired()
  16. .HasComment("Reference to tenant that setting belongs");
  17. entity.Property(e => e.UserId).IsRequired()
  18. .HasComment("Reference to user assigned to tenant");
  19. // relationships
  20. entity.HasOne(d => d.Tenant)
  21. .WithMany()
  22. .HasForeignKey(d => d.TenantId)
  23. .HasConstraintName("REL_TENANTUSER_TENANT_ID");
  24. entity.HasOne(d => d.User)
  25. .WithMany()
  26. .HasForeignKey(d => d.UserId)
  27. .HasConstraintName("REL_TENANTUSER_USER_ID");
  28. }
  29. );
  30. }
  31. }
  32. }