public void Configure(EntityTypeBuilder <Lead> builder) { builder.ToTable("Lead"); builder.HasKey(l => l.Id); builder.Property(l => l.Title) .HasColumnType("varchar(60)") .IsRequired(); builder.Property(l => l.Status) .HasColumnType("varchar(15)") //.HasConversion<string>( e => e.ToString(), s => (LeadStatus)Enum.Parse(typeof(LeadStatus), s)) //.HasConversion(new EnumToStringConverter<LeadStatus>()) .HasConversion <string>() .IsRequired(); // 1 -> * builder .HasOne(l => l.CreatedBy) .WithMany(p => p.LeadsCreatedByMe) .HasForeignKey(l => l.CreatedById) .OnDelete(DeleteBehavior.Restrict) .IsRequired(); // * -> 1 //builder // .HasMany(l => l.Coments) // .WithOne(c => c.Lead) // .HasForeignKey(c => c.LeadId); builder .ConfigMapDefaultFields(); }
public void Configure(EntityTypeBuilder <Coment> builder) { builder.ToTable("Coment"); builder.HasKey(c => c.Id); builder .Property(c => c.Description) .HasColumnType("varchar(500)"); builder .HasMany(c => c.Answers) .WithOne(a => a.FatherComent) .HasForeignKey(a => a.FatherComentId) .OnDelete(DeleteBehavior.ClientSetNull); builder .HasOne(c => c.CreatedBy) .WithMany(p => p.ComentsByMe) .HasForeignKey(c => c.CreatedById) .OnDelete(DeleteBehavior.Cascade) .IsRequired(); builder .HasOne(c => c.Lead) .WithMany(l => l.Coments) .HasForeignKey(c => c.LeadId) .HasPrincipalKey(c => c.Id) .OnDelete(DeleteBehavior.Cascade) .IsRequired(); builder .ConfigMapDefaultFields(); }
public void Configure(EntityTypeBuilder <Person> builder) { builder .Property(p => p.ImageUrl) .HasColumnType("varchar(500)"); builder .Property(p => p.Name) .HasColumnType("varchar(100)") .IsRequired(); builder .Property(p => p.Resume) .HasColumnType("varchar(1000)"); builder .Property(p => p.Job) .HasColumnType("varchar(50)"); builder .Property(p => p.Phone) .HasColumnType("varchar(11)") .HasConversion <string>(p => p.Number, s => (Phone)s); builder .Property(p => p.UrlGithub) .HasColumnType("varchar(500)"); builder .HasMany(p => p.LeadsCreatedByMe) .WithOne(l => l.CreatedBy) .HasForeignKey(l => l.CreatedById) .OnDelete(DeleteBehavior.Restrict); // Projects que o Person é Responsaável builder .HasMany(p => p.ProjectsResponsible) .WithOne(proj => proj.Responsible) .HasForeignKey(proj => proj.ResponsibleId) .OnDelete(DeleteBehavior.Restrict); builder .ConfigMapDefaultFields(); // Skills do Person - Não precisa mapeara qui, porque já é mapeado no PersonSkill //builder // .HasMany(p => p.MySkills) // .WithOne(sp => sp.Person) // .HasForeignKey(sp => sp.PersonId); }
public void Configure(EntityTypeBuilder <ProjectSkill> builder) { builder.ToTable("ProjectSkill"); builder.HasKey(ps => new { ps.ProjectId, ps.SkillId }); builder .HasOne(ps => ps.Project) .WithMany(p => p.Skills) .HasForeignKey(ps => ps.ProjectId); builder .HasOne(ps => ps.Skill) .WithMany(p => p.ProjectSkills) .HasForeignKey(ps => ps.SkillId); builder .ConfigMapDefaultFields(); }
public void Configure(EntityTypeBuilder <ProjectPerson> builder) { builder.ToTable("ProjectPerson"); builder.HasKey(pp => new { pp.ProjectId, pp.PersonId }); builder .HasOne(pp => pp.Project) .WithMany(p => p.Members) .HasForeignKey(pp => pp.ProjectId); builder .HasOne(pp => pp.Person) .WithMany(p => p.ProjectsMember) .HasForeignKey(pp => pp.PersonId); builder .ConfigMapDefaultFields(); }
public void Configure(EntityTypeBuilder <Project> builder) { builder.ToTable("Project"); builder.HasKey(p => p.Id); builder .Property(p => p.LogoUrl) .HasColumnType("varchar(500)"); builder .Property(p => p.Name) .HasColumnType("varchar(100)") .IsRequired(); builder .Property(p => p.Company) .HasColumnType("varchar(100)") .IsRequired(); builder .Property(p => p.Description) .HasColumnType("varchar(1000)"); builder .Property(p => p.BeginDate) .HasColumnType("datetime") .IsRequired(); builder .Property(p => p.EndDate) .HasColumnType("datetime") .IsRequired(); builder .HasOne(p => p.Responsible) .WithMany(r => r.ProjectsResponsible) .HasForeignKey(p => p.ResponsibleId) .IsRequired(); builder .ConfigMapDefaultFields(); }
public void Configure(EntityTypeBuilder <PersonLead> builder) { builder.ToTable("PersonLead"); builder.HasKey(pl => new { pl.LeadId, pl.PersonId }); builder .HasOne(pl => pl.Lead) .WithMany(l => l.PersonsFollowing) .HasForeignKey(pl => pl.LeadId); builder .HasOne(pl => pl.Person) .WithMany(p => p.LeadsFollowedByMe) .HasForeignKey(pl => pl.PersonId); builder .ConfigMapDefaultFields(); builder .Ignore(pl => pl.Id); }
public void Configure(EntityTypeBuilder <User> builder) { builder.ToTable("Person"); builder .HasKey(p => p.Id); builder .Property(p => p.Username) .HasColumnType("varchar(50)"); builder .Property(p => p.Password) .HasColumnType("varchar(50)") .HasConversion <string>( p => p.ToUnsecuredString(), s => s.ToSecuredString() ); builder .ConfigMapDefaultFields(); }
public void Configure(EntityTypeBuilder <PersonSkill> builder) { builder.ToTable("PersonSkill"); builder.HasKey(ps => new { ps.PersonId, ps.SkillId }); builder .HasOne(ps => ps.Person) .WithMany(p => p.MySkills) .HasForeignKey(ps => ps.PersonId); builder .HasOne(ps => ps.Skill) .WithMany(s => s.PersonSkill) .HasForeignKey(ps => ps.SkillId); builder .Ignore(ps => ps.Id); builder .ConfigMapDefaultFields(); }