ProjetoConfiguration.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  2. using Microsoft.EntityFrameworkCore;
  3. using ConcursoProjetos.Domain.Entities;
  4. namespace ConcursoProjetos.Data.Configurations;
  5. public class ProjetoConfiguration : IEntityTypeConfiguration<Projeto>
  6. {
  7. public void Configure(EntityTypeBuilder<Projeto> builder)
  8. {
  9. builder.ToTable("Projeto");
  10. builder.HasKey(p => p.Id);
  11. builder.Property(p => p.Id)
  12. .ValueGeneratedOnAdd();
  13. builder.Property(p => p.IsDeleted)
  14. .HasColumnType("bit");
  15. builder.Property(p => p.Nome)
  16. .HasColumnType("nvarchar")
  17. .HasMaxLength(100);
  18. builder.Property(p => p.NumeroUnidades)
  19. .HasColumnType("int");
  20. builder.Property(p => p.ResponsavelTecnicoCpf)
  21. .HasColumnType("nvarchar")
  22. .HasMaxLength(11);
  23. builder.Property(p => p.ResponsavelTecnicoNomeCompleto)
  24. .HasColumnType("nvarchar")
  25. .HasMaxLength(100);
  26. builder.Property(p => p.ResponsavelTecnicoTelefone)
  27. .HasColumnType("nvarchar")
  28. .HasMaxLength(20);
  29. builder.Property(p => p.ResponsavelTecnicoEmail)
  30. .HasColumnType("nvarchar")
  31. .HasMaxLength(100);
  32. builder.HasOne(c => c.Candidato)
  33. .WithMany()
  34. .HasForeignKey(c => c.CandidatoId)
  35. .OnDelete(DeleteBehavior.Restrict);
  36. }
  37. }