using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Purrse.Core.Models; namespace Purrse.Data.Configurations; public class AccountConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("accounts"); builder.HasKey(a => a.Id); builder.Property(a => a.Name).HasMaxLength(200).IsRequired(); builder.Property(a => a.Institution).HasMaxLength(200); builder.Property(a => a.AccountNumber).HasMaxLength(50); builder.Property(a => a.Balance).HasPrecision(18, 2); builder.Property(a => a.CreditLimit).HasPrecision(18, 2); builder.Property(a => a.InterestRate).HasPrecision(8, 4); builder.Property(a => a.Notes).HasMaxLength(1000); builder.HasOne(a => a.User) .WithMany(u => u.Accounts) .HasForeignKey(a => a.UserId) .OnDelete(DeleteBehavior.Cascade); builder.HasOne(a => a.LoanDetail) .WithOne(l => l.Account) .HasForeignKey(l => l.AccountId) .OnDelete(DeleteBehavior.Cascade); builder.HasIndex(a => a.UserId); } }