Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- using Minerva.Domain.Entities;
- namespace Minerva.Infra.Data.Configurations
- {
- public class PersonConfiguration : IEntityTypeConfiguration<Person>
- {
- public void Configure(EntityTypeBuilder<Person> builder)
- {
- builder.OwnsOne(o => o.Name,
- sa =>
- {
- sa.Property(p => p.FullName)
- .HasColumnName("FullName")
- .HasComputedColumnSql("CONCAT(FirstName, ' ', LastName) PERSISTED");
- sa.Property(p => p.FirstName)
- .HasColumnName("FirstName")
- .HasMaxLength(50)
- .IsRequired();
- sa.Property(p => p.LastName)
- .HasColumnName("LastName")
- .HasMaxLength(50)
- .IsRequired();
- });
- builder.OwnsOne(o => o.FiscalId,
- sa =>
- {
- sa.Property(p => p.Number)
- .HasColumnName("Number")
- .HasMaxLength(20)
- .IsRequired();
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement