using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using SPMS.Domain.Entities; namespace SPMS.Infrastructure.Persistence.Configurations; public class FileEntityConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("File"); builder.HasKey(e => e.Id); builder.Property(e => e.Id).ValueGeneratedOnAdd(); builder.Property(e => e.ServiceId).IsRequired(); builder.Property(e => e.FileName).HasMaxLength(200).IsRequired(); builder.Property(e => e.FilePath).HasMaxLength(500).IsRequired(); builder.Property(e => e.FileSize).IsRequired(); builder.Property(e => e.FileType).HasMaxLength(20).IsRequired(); builder.Property(e => e.MimeType).HasMaxLength(100); builder.Property(e => e.CreatedAt).IsRequired(); builder.Property(e => e.CreatedBy).IsRequired(); builder.HasOne(e => e.Service) .WithMany() .HasForeignKey(e => e.ServiceId) .OnDelete(DeleteBehavior.Restrict); builder.HasOne(e => e.CreatedByAdmin) .WithMany() .HasForeignKey(e => e.CreatedBy) .OnDelete(DeleteBehavior.Restrict); } }