using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using PnvPanel.Domain.Nodes; namespace PnvPanel.Infrastructure.Persistence.Configurations; public class NodeConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("Nodes"); builder.HasKey(x => x.Id); builder.Property(x => x.Name).IsRequired().HasMaxLength(100); builder.Property(x => x.BaseAddress) .IsRequired() .HasMaxLength(500) .HasConversion(uri => uri.ToString(), s => new Uri(s, UriKind.Absolute)); builder.Property(x => x.Location).HasMaxLength(100); builder.Property(x => x.Status).HasConversion().HasMaxLength(32); builder.OwnsOne(x => x.Credentials, credentials => { credentials.Property(c => c.Username).HasColumnName("CredentialsUsername").IsRequired().HasMaxLength(200); credentials.Property(c => c.ProtectedPassword).HasColumnName("CredentialsProtectedPassword").IsRequired(); }); } }