Lazy Load only loads data when subtract the solution

0

I have the following problem: When I make the Entity Framework add a data in the base, it does, but it does not return the attributes of type loaded Class. For them to load normally, I need to reestablish the solution.

My mapping is correct ... My entity is set to Virtual and the mapping of the class and DTO is correct.

Does anyone have a clue what to do?

    
asked by anonymous 25.10.2018 / 21:56

1 answer

0

I know two important settings when it comes to Lazy Load and that have helped me over time:

1) Reiterate the context setting:

Example:

   contexto.Configuration.LazyLoadingEnabled = false;

2) When the class has relationships, you must include them [.Include (x => x. {COLECAO})]:

Example:

   var produtos = _contexto.Produtos
                           .Where(p => p.Name == "Camisa")
                           .Include(x => x.Cores)
                           .ToList();

I hope it helps.

    
25.10.2018 / 23:37