| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using Microsoft.EntityFrameworkCore;
- using Quadarax.Application.QLiberace.Common.Entities.Base.DaoMapper;
- namespace Quadarax.Application.QLiberace.Base.Entities.DaoMapper
- {
- public class TenantCurrencyDm : KeylessDm<TenantCurrency>
- {
- public override void Map(ModelBuilder builder)
- {
- if (builder == null) throw new ArgumentNullException(nameof(builder));
- base.Map(builder);
- builder.Entity<TenantCurrency>(entity =>
- {
- entity.ToTable(Constants.Modules.Base.TblTenantCurrency, Constants.Modules.Base.Schema);
- entity.HasKey(tu => new { tu.CurerrencyId, tu.TenantId });
- // foreign keys
- entity.Property(e => e.TenantId).IsRequired()
- .HasComment("Reference to tenant that setting belongs");
- entity.Property(e => e.CurerrencyId).IsRequired()
- .HasComment("Reference to currency assigned to tenant");
- // relationships
- entity.HasOne(pc => pc.Tenant)
- .WithMany(p => p.Currencies)
- .HasForeignKey(pc => pc.TenantId)
- .HasConstraintName("REL_TENANTCURRENCY_TENANT_ID");
- entity.HasOne(pc => pc.Currency)
- .WithMany(c => c.Tenants)
- .HasForeignKey(pc => pc.CurerrencyId)
- .HasConstraintName("REL_TENANTCURRENCY_CURRENCY_ID");
- }
- );
- }
- }
- }
|