Entity Framework How to add a table with the navigation properties

0

I have the Class: Land

public class Land 

{
    [Key]
    public int LandId { get; set; }
    public string LandName { get; set; }
    public float Area { get; set; }
    public int OwnerId { get; set; }
    [NotMapped]
    public int DepartmentId { get; set; }
    [NotMapped]
    public int MunicipalityId { get; set; }
    public int RegionId { get; set; }
    public virtual Region Regions { get; set; }
    public virtual Owner Owners { get; set; }
}

I can check the Land, Owners and Regions entities through the navigation properties, here I show the Controller code.

 var lands = db.Lands
               .Include(l => l.Owners)
               .Include(l => l.Regions);

     return View(lands.ToList());

The problem is how I include another entity (Municipalitys) which is related to the Regions entity

I leave this image to clarify the question:

    
asked by moncada 18.10.2018 в 07:40
source

0 answers