CandidatoConfiguration.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  2. using Microsoft.EntityFrameworkCore;
  3. using ConcursoProjetos.Domain.Entities;
  4. namespace ConcursoProjetos.Data.Configurations;
  5. public class CandidatoConfiguration : IEntityTypeConfiguration<Candidato>
  6. {
  7. public void Configure(EntityTypeBuilder<Candidato> builder)
  8. {
  9. builder.ToTable("Candidato");
  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.Cpf)
  16. .HasColumnType("nvarchar")
  17. .HasMaxLength(11);
  18. builder.Property(p => p.NomeCompleto)
  19. .HasColumnType("nvarchar")
  20. .HasMaxLength(100);
  21. builder.Property(p => p.Telefone)
  22. .HasColumnType("nvarchar")
  23. .HasMaxLength(20);
  24. builder.Property(p => p.Email)
  25. .HasColumnType("nvarchar")
  26. .HasMaxLength(100);
  27. builder.Property(p => p.TipoPessoa)
  28. .HasColumnType("bit");
  29. builder.Property(p => p.Cnpj)
  30. .HasColumnType("nvarchar")
  31. .HasMaxLength(14);
  32. builder.Property(p => p.EmpresaRazaoSocial)
  33. .HasColumnType("nvarchar")
  34. .HasMaxLength(100);
  35. builder.Property(p => p.EmpresaTelefone)
  36. .HasColumnType("nvarchar")
  37. .HasMaxLength(20);
  38. builder.Property(p => p.EmpresaEmail)
  39. .HasColumnType("nvarchar")
  40. .HasMaxLength(100);
  41. builder.HasOne(c => c.User)
  42. .WithMany()
  43. .HasForeignKey(c => c.UserId)
  44. .OnDelete(DeleteBehavior.Restrict);
  45. }
  46. }