| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using Quadarax.Application.QLiberace.Common.Entities.Base.DaoMapper;
- using Microsoft.EntityFrameworkCore;
- namespace Quadarax.Application.QLiberace.Base.Entities.DaoMapper
- {
- public class TenantUserDm : KeylessDm<TenantUser>
- {
- public override void Map(ModelBuilder builder)
- {
- if (builder == null) throw new ArgumentNullException(nameof(builder));
- base.Map(builder);
- builder.Entity<TenantUser>(entity =>
- {
- entity.ToTable(Constants.Modules.Base.TblTenantUser, Constants.Modules.Base.Schema);
- entity.HasKey(tu => new { tu.UserId, tu.TenantId });
- // foreign keys
- entity.Property(e => e.TenantId).IsRequired()
- .HasComment("Reference to tenant that setting belongs");
- entity.Property(e => e.UserId).IsRequired()
- .HasComment("Reference to user assigned to tenant");
- // relationships
- entity.HasOne(pc => pc.Tenant)
- .WithMany(p => p.Users)
- .HasForeignKey(pc => pc.TenantId)
- .HasConstraintName("REL_TENANTUSER_TENANT_ID");
- entity.HasOne(pc => pc.User)
- .WithMany(c => c.Tenants)
- .HasForeignKey(pc => pc.UserId)
- .HasConstraintName("REL_TENANTUSER_USER_ID");
- }
- );
- }
- }
- }
|