This forum is not used anymore. Please ask new questions to Stack Overflow: https://stackoverflow.com/questions/tag ... ort=newest (use aspnetboilerplate tag).
By diego
#4781 Hello,
i have few questions about entities design, suppose we have these 2 classes

Code: Select allpublic class Partner : FullAuditedEntity, IPassivable, IMayHaveTenant
{
   public const int MaxNameLength = 100;

   [Required]
   [StringLength(MaxNameLength)]
   public virtual string Name { get; set; }

   [Required]
   public virtual PartnerType PartnerType { get; set; }      
   
   public virtual int? TenantId { get; set; }
   public virtual bool IsActive { get; set; }   
   
}

public class PartnerType : Entity, IPassivable, IMayHaveTenant
{
        public const int MaxNameLength = 100;

        [Required]
        [StringLength(MaxNameLength)]
        public virtual string Name { get; set; }

        public virtual int? TenantId { get; set; }
        public virtual bool IsActive { get; set; }   
}


1 - It's right use the [Required] attribute on the PartnerType property of the Partner class?
2 - Whenever there is a relation between class, i must use the ForeignKey attributes?
3 - With the [Required] attribute on the PartnerType property of the Partner class i have a issue trying deleting a Partner, below the code
Code: Select allpublic async Task DeletePartner(IdInput input)
{   
   await _partnersRepository.DeleteAsync(input.Id);
}

The delete (indeed soft delete) fail reporting this validation error: "The PartnerType field is required". Why?

Thanks in advance,
Diego