54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using Prefab.Data.Entities;
|
|
|
|
namespace Prefab.Data.Configs;
|
|
|
|
/// <summary>
|
|
/// Configuration class for the <see cref="SeederLog"/> entity.
|
|
/// </summary>
|
|
public class SeederLogConfig() : Prefab.Data.Configs.EntityConfig<SeederLog>(nameof(IPrefabDb.SeederLogs))
|
|
{
|
|
/// <summary>
|
|
/// Configuration of Entity Framework mapping for the <see cref="SeederLog"/> entity.
|
|
/// </summary>
|
|
public override void Configure(EntityTypeBuilder<SeederLog> builder)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(builder);
|
|
|
|
builder
|
|
.HasKey(x => x.Id);
|
|
|
|
builder
|
|
.Property(x => x.Id)
|
|
.ValueGeneratedOnAdd();
|
|
|
|
builder.Property(x => x.SeederName)
|
|
.HasMaxLength(Rules.SeederNameMaxLength)
|
|
.IsRequired();
|
|
|
|
builder.Property(x => x.RunMode)
|
|
.HasMaxLength(Rules.SeederRunModeMaxLength)
|
|
.IsRequired();
|
|
|
|
builder
|
|
.Property(x => x.RunAt)
|
|
.IsRequired();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Validation rules for the <see cref="SeederLog"/> entity.
|
|
/// </summary>
|
|
public static class Rules
|
|
{
|
|
/// <summary>
|
|
/// Maximum length to set for the seeder name.
|
|
/// </summary>
|
|
public const int SeederNameMaxLength = 256;
|
|
|
|
/// <summary>
|
|
/// Maximum length to set for the seeder name.
|
|
/// </summary>
|
|
public const int SeederRunModeMaxLength = 64;
|
|
}
|
|
}
|