Files
Backend-Api/CompanyManagment.EFCore/Mapping/AuthorizedBankDetailsMapping.cs

35 lines
1.5 KiB
C#

using Company.Domain.AuthorizedBankDetailsAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping
{
public class AuthorizedBankDetailsMapping : IEntityTypeConfiguration<AuthorizedBankDetails>
{
public void Configure(EntityTypeBuilder<AuthorizedBankDetails> builder)
{
builder.ToTable("AuthorizedBankDetails");
builder.HasKey(x => x.id);
builder.Property(x => x.CardNumber).HasMaxLength(50);
builder.Property(x => x.AccountNumber).HasMaxLength(50);
builder.Property(x => x.IBan).HasMaxLength(50);
builder.Property(x => x.BankName).HasMaxLength(100);
// Configure owners as owned entities (value objects)
builder.OwnsMany(x => x.OwnersList, ownersBuilder =>
{
ownersBuilder.ToTable("AuthorizedBankDetailsOwners");
ownersBuilder.WithOwner().HasForeignKey("AuthorizedBankDetailsId");
ownersBuilder.Property<int>("Id").ValueGeneratedOnAdd();
ownersBuilder.HasKey("Id");
ownersBuilder.Property(x => x.FName).HasMaxLength(100);
ownersBuilder.Property(x => x.LName).HasMaxLength(100);
ownersBuilder.Property(x => x.NationalIdentifier).HasMaxLength(20);
ownersBuilder.Property(x => x.CustomerType).HasMaxLength(50);
});
}
}
}