using Asentrafin.Api.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Asentrafin.Api.Data.Configurations; public class TransactionCategoryConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("transaction_categories"); builder.HasKey(category => category.Id); builder.Property(category => category.Name).HasMaxLength(256).IsRequired(); builder.Property(category => category.Slug).HasMaxLength(256).IsRequired(); builder.Property(category => category.PlaidPrimary).HasMaxLength(128); builder.Property(category => category.PlaidDetailed).HasMaxLength(128); builder.HasIndex(category => category.Slug).IsUnique(); builder.HasIndex(category => new { category.PlaidPrimary, category.PlaidDetailed }); builder.HasOne(category => category.Parent) .WithMany(category => category.Children) .HasForeignKey(category => category.ParentId) .OnDelete(DeleteBehavior.Restrict); } }