Init
This commit is contained in:
43
Prefab.Catalog/Data/Configs/CategoryConfig.cs
Normal file
43
Prefab.Catalog/Data/Configs/CategoryConfig.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user