Fixed configurations of owned types

This commit is contained in:
2024-08-15 23:40:50 +03:00
parent 54e31d41fc
commit 72924fb037
18 changed files with 83 additions and 81 deletions

View File

@@ -1,18 +1,23 @@
using Domains.ApplicantDomain;
using Domains;
using Domains.ApplicantDomain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Applicants.Configuration;
public class AddressConfiguration : IEntityTypeConfiguration<Address>
public static class AddressConfiguration<T> where T : class, IEntity
{
public void Configure(EntityTypeBuilder<Address> entity)
public static void Configure(OwnedNavigationBuilder<T, Address> entity)
{
entity.HasOne(a => a.Country).WithMany().OnDelete(DeleteBehavior.Restrict);
entity.HasOne(a => a.City).WithMany().OnDelete(DeleteBehavior.Restrict);
entity.Property(p => p.Street)
.IsUnicode(false)
.HasMaxLength(100);
entity.Property(p => p.Building)
.IsUnicode(false)
.HasMaxLength(10);
}
}
}