using Core.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Data.Configurations { public class NoteConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasKey(n => n.Id); // Indexes builder.HasIndex(n => n.Title); builder.HasIndex(n => n.CreatedAt); builder.HasIndex(n => n.IsPinned); builder.HasIndex(n => n.IsDeleted); // Constraints builder.Property(n => n.Title) .IsRequired() .HasMaxLength(200); builder.Property(n => n.Content) .HasColumnType("TEXT"); builder.Property(n => n.CreatedBy) .HasMaxLength(255); builder.Property(n => n.LastModifiedBy) .HasMaxLength(255); // Relationships builder.HasMany(n => n.NoteHistories) .WithOne(h => h.Note) .HasForeignKey(h => h.NoteId) .IsRequired() .OnDelete(DeleteBehavior.Cascade); } } }