0

Is there a way to disable lazy loading for given, specific navigation property?

I have database-first aproach, and I need to disable lazy loading for one given navigation property, because table that is connected to is so huge, that it makes my app load long time.

I tried to delete this prop from edmx model, but it broke all my LINQ to Entities queries that use this prop (even when it's loaded by .Include()).

NotSupportedException

The specified type member 'TimesheetWorklog' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.

I found one way to do that, but it's not perfect. I created Partial class and moved this property to that class, to make it no-virtual, and disable lazy-loading, but edmx is still generating this prop in base model and makes me to discard changes whenever I update my edmx.

Thanks! Kris

  • 1
    You can easily disable the lazy loading for a single navigation property by simply not accessing it. Also this might be helpful: http://stackoverflow.com/questions/24022957/entity-framework-how-to-disable-lazy-loading-for-specific-query – romanoza Feb 11 '16 at 09:20
  • Ok, you are right, but in my case I need to load it almost always, but never whole, huge, table, only a part of it. Now it is gathered by separate query, where only a part of table is fetched. – Krzysiek Szymczak Feb 11 '16 at 09:27

0 Answers0