using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Prefab.Data.Entities; namespace Prefab.Data.Configs { /// /// Entity Framework Core configuration for the entity. /// public class AuditLogItemConfig() : Prefab.Data.Configs.EntityConfig(nameof(IPrefabDb.AuditLogItems)) { /// /// Configures the properties and relationships for the entity. /// /// The builder to be used to configure the entity type. public override void Configure(EntityTypeBuilder builder) { builder.HasKey(e => e.Id); builder.Property(e => e.Property) .HasMaxLength(Rules.PropertyMaxLength) .IsRequired(); builder.Property(e => e.OldValue) .HasMaxLength(Rules.ValueMaxLength); builder.Property(e => e.NewValue) .HasMaxLength(Rules.ValueMaxLength); builder.HasOne(e => e.AuditLog) .WithMany(a => a.Items) .HasForeignKey(e => e.AuditLogId) .OnDelete(DeleteBehavior.Cascade); } /// /// Validation rules and settings for properties. /// public static class Rules { /// Maximum length for the property name. public const int PropertyMaxLength = 100; /// Maximum length for the value fields. public const int ValueMaxLength = 1000; } } }