using InvoiceMaster.Core.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace InvoiceMaster.Infrastructure.Data.Configurations; public class SupplierCacheConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("supplier_cache"); builder.HasKey(e => e.Id); builder.Property(e => e.SupplierNumber) .IsRequired() .HasMaxLength(50); builder.Property(e => e.Name) .IsRequired() .HasMaxLength(255); builder.Property(e => e.OrganisationNumber) .HasMaxLength(20); builder.Property(e => e.Address1) .HasMaxLength(255); builder.Property(e => e.Address2) .HasMaxLength(255); builder.Property(e => e.Postcode) .HasMaxLength(20); builder.Property(e => e.City) .HasMaxLength(100); builder.Property(e => e.Country) .HasMaxLength(100); builder.Property(e => e.Phone) .HasMaxLength(50); builder.Property(e => e.Email) .HasMaxLength(255); builder.Property(e => e.BankgiroNumber) .HasMaxLength(50); builder.Property(e => e.PlusgiroNumber) .HasMaxLength(50); builder.HasIndex(e => new { e.ConnectionId, e.SupplierNumber }) .IsUnique(); builder.HasIndex(e => e.ConnectionId); builder.HasIndex(e => e.OrganisationNumber); builder.HasIndex(e => e.Name); builder.HasIndex(e => e.ExpiresAt); builder.HasOne(e => e.Connection) .WithMany() .HasForeignKey(e => e.ConnectionId) .OnDelete(DeleteBehavior.Cascade); } }