This commit is contained in:
2025-10-27 17:39:18 -04:00
commit 31f723bea4
1579 changed files with 642409 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Prefab.Data.Entities;
namespace Prefab.Data.Configs
{
/// <summary>
/// Entity Framework Core configuration for the <see cref="AuditLog"/> entity.
/// </summary>
public class AuditLogConfig() : Prefab.Data.Configs.EntityConfig<AuditLog>(nameof(IPrefabDb.AuditLogs))
{
/// <summary>
/// Configures the properties and relationships for the <see cref="AuditLog"/> entity.
/// </summary>
/// <param name="builder">The builder to be used to configure the entity type.</param>
public override void Configure(EntityTypeBuilder<AuditLog> builder)
{
builder.HasKey(e => e.Id);
builder.Property(e => e.Entity)
.HasMaxLength(Rules.EntityMaxLength)
.IsRequired();
builder.Property(e => e.State)
.IsRequired();
builder.Property(e => e.CreatedBy)
.IsRequired();
builder.Property(e => e.CreatedOn)
.IsRequired();
builder.HasMany(e => e.Items)
.WithOne(i => i.AuditLog)
.HasForeignKey(i => i.AuditLogId)
.OnDelete(DeleteBehavior.Cascade);
}
/// <summary>
/// Validation rules and settings for <see cref="AuditLog"/> properties.
/// </summary>
public static class Rules
{
/// <summary>Maximum length for the Entity name.</summary>
public const int EntityMaxLength = 200;
}
}
}