25 lines
1023 B
C#
25 lines
1023 B
C#
using Company.Domain.FinancialInvoiceAgg;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace CompanyManagment.EFCore.Mapping;
|
|
|
|
public class FinancialInvoiceMapping:IEntityTypeConfiguration<FinancialInvoice>
|
|
{
|
|
public void Configure(EntityTypeBuilder<FinancialInvoice> builder)
|
|
{
|
|
builder.HasKey(x => x.id);
|
|
|
|
builder.Property(x => x.Status).HasConversion<string>().HasMaxLength(20);
|
|
builder.Property(x => x.PaidAt).IsRequired(false);
|
|
builder.Property(x => x.Description).HasMaxLength(800);
|
|
builder.Property(x => x.InvoiceNumber).HasMaxLength(22);
|
|
|
|
builder.HasMany(x => x.Items).WithOne(x => x.FinancialInvoice)
|
|
.HasForeignKey(x => x.FinancialInvoiceId).IsRequired().OnDelete(DeleteBehavior.Cascade);
|
|
builder.HasMany(x => x.PaymentTransactions).WithOne(x => x.FinancialInvoice)
|
|
.HasForeignKey(x => x.FinancialInvoiceId).IsRequired(false).OnDelete(DeleteBehavior.NoAction);
|
|
|
|
|
|
}
|
|
} |