help with entityframework query when showing relationships

1

Hello friends, I appeal to you to solve the following question

I have two entities named MtoProcedimientos and MtoZonas

Mtoprocedures has the following relationship

public int MtoProcedimientoId { get; set; }
public virtual ICollection<MtoZona> mtoZonas { get; set; }

and in the entity mtozonas has the relationship

public int MtoProcedimientoId { get; set; }
public virtual MtoProcedimiento mtoProcedimiento { get; set; }

now when I make a query as follows.

 // GET: Procedimientos/Details/5
    public ActionResult Details(int? id)
    {            

        if (id == null)
        {
            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        }

        var mtoProcedimiento = db.MtoProcedimientos.Find(id);


        if (mtoProcedimiento == null)
        {
            return HttpNotFound();
        }

        return View(mtoProcedimiento);
    }

What I want is to obtain the information of the 2 entities, to make a summary; but although there are records in the table of regions that meet the conditions, I do not obtain any record.

attached image

believe they can help me, thank you in advance

    
asked by Horacio Xochitemol 31.05.2018 в 15:58
source

2 answers

1

In order for ef to bring you relationships or navigation properties you should configure it includes

You can see link

    
answered by 31.05.2018 в 20:10
0

I told you that I solved this problem by removing the following line from my DBContext.

//this.Configuration.LazyLoadingEnabled = false;
    
answered by 05.06.2018 в 18:32