44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using Prefab.Base.Catalog.Categories;
|
|
using Prefab.Catalog.Domain.Entities;
|
|
|
|
namespace Prefab.Catalog.Data.Configs;
|
|
|
|
public class CategoryConfig() : Prefab.Data.Configs.EntityConfig<Category>(nameof(IModuleDb.Categories), IModuleDb.SchemaName.ToLower())
|
|
{
|
|
public override void Configure(EntityTypeBuilder<Category> builder)
|
|
{
|
|
base.Configure(builder);
|
|
|
|
builder.HasKey(e => e.Id);
|
|
|
|
builder.Property(e => e.RowVersion)
|
|
.IsRowVersion();
|
|
|
|
builder.Property(e => e.Name)
|
|
.HasMaxLength(CategoryRules.NameMaxLength)
|
|
.IsRequired();
|
|
|
|
builder.Property(e => e.Description)
|
|
.HasMaxLength(CategoryRules.DescriptionMaxLength);
|
|
|
|
builder.Property(e => e.Slug)
|
|
.HasMaxLength(CategoryRules.SlugMaxLength);
|
|
|
|
builder.HasIndex(e => e.Slug)
|
|
.IsUnique()
|
|
.HasFilter("[Slug] IS NOT NULL");
|
|
|
|
builder.Property(e => e.DisplayOrder);
|
|
|
|
builder.Property(e => e.IsFeatured);
|
|
|
|
builder.Property(e => e.HeroImageUrl)
|
|
.HasMaxLength(CategoryRules.HeroImageUrlMaxLength);
|
|
|
|
builder.Property(e => e.Icon)
|
|
.HasMaxLength(CategoryRules.IconMaxLength);
|
|
}
|
|
}
|