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

36 lines
1.3 KiB
C#

using Company.Domain.LawAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping
{
public class LawMapping : IEntityTypeConfiguration<Law>
{
public void Configure(EntityTypeBuilder<Law> builder)
{
builder.ToTable("Law");
builder.HasKey(x => x.id);
builder.Property(x => x.Title).HasMaxLength(255).IsRequired();
builder.Property(x => x.IsActive).IsRequired();
builder.Property(x => x.Type).HasConversion<string>().HasMaxLength(50);
builder.OwnsMany(x => x.Items, navigationBuilder =>
{
navigationBuilder.ToTable("LawItem");
navigationBuilder.HasKey(x => x.Id);
navigationBuilder.WithOwner().HasForeignKey(x => x.LawId);
navigationBuilder.Property(x => x.Header).HasMaxLength(255);
navigationBuilder.Property(x => x.Details).IsRequired();
navigationBuilder.Property(x => x.OrderNumber).IsRequired();
});
builder.Property(x => x.NotificationsJson)
.HasColumnName("Notifications")
.HasMaxLength(3000); // Set max length to 1000, adjust as needed
builder.Property(x => x.HeadTitle).HasMaxLength(200);
}
}
}