I want to do one-to-many relationship in EF where one and only Territory has multiple regions, but when I parse the model in Power Tools it does not recognize it.
Region
[Table("Regiao")]
public class Regiao
{
[Key]
[DisplayFormat(DataFormatString = "{0:0000}", ApplyFormatInEditMode = true)]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long RegiaoID { get; set; }
[Display(Name = "Região")]
[Column(TypeName = "varchar")]
[StringLength(50, ErrorMessage = "O {0} deve ser de pelo menos {2} caracteres.", MinimumLength = 2)]
[Required(ErrorMessage = "Campo Obrigatório")]
public string RegiaoDescricao { get; set; }
[ForeignKey("FKTerritorioID")]
public long TerritorioID { get; set; }
public virtual Territorio Territorio { get; set; }
}
Territory
[Table("Territorio")]
public class Territorio
{
[Key]
[DisplayFormat(DataFormatString = "{0:0000}", ApplyFormatInEditMode = true)]
public long TerritorioID { get; set; }
[Required(ErrorMessage="Campo Obrigatório")]
public string TerritorioDescricao { get; set; }
public ICollection<Regiao> Regioes { get; set; }
}
Context
public class DbEmpresaContext : DbContext
{
public DbEmpresaContext()
: base("connDBEmpresaModelo")
{
}
public DbSet<Regiao> Regioes { get; set; }
public DbSet<Territorio> Territorios { get; set; }
}