I\'m a very strange behavior with EF code first approach and associations. I have two entities:
public class GlobalKpiSectionn
{
public GlobalKpiSection(
EF disabled lazy loading when it validates the entities. It does this to avoid unnecessary round trips to database due to the validations placed on navigational properties.
Model the scalar property in your entity and place the validation attribute there.
public class Region
{
public int RegionId { get; set; }
public bool IsMain { get; set; }
[Required]
public int? KpiSectionId { get; set; }
public virtual GlobalKpiSection KpiSection { get; set; }
}