using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using mws.backend.dotnet.domain.Documents; namespace mws.backend.dotnet.infrastructure.Persistence.Configuration; public class DocumentConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder e) { e.ToTable("documents"); e.HasKey(d => d.Id); e.Property(d => d.Title).HasMaxLength(300).IsRequired(); e.Property(d => d.Type).HasConversion().HasMaxLength(20); e.Property(d => d.Content).HasColumnType("text"); e.HasIndex(d => new { d.ProjectId, d.ParentId }); e.HasIndex(d => d.ParentId); e.HasOne(d => d.Parent) .WithMany(d => d.Children) .HasForeignKey(d => d.ParentId) .OnDelete(DeleteBehavior.Restrict); } }