Init
This commit is contained in:
48
Prefab/Data/Configs/AuditLogConfig.cs
Normal file
48
Prefab/Data/Configs/AuditLogConfig.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user