Join the Stack Overflow Community
Stack Overflow is a community of 6.5 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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

share|improve this question
1  
You can easily disable the lazy loading for a single navigation property by simply not accessing it. Also this might be helpful: stackoverflow.com/questions/24022957/… – romanoza Feb 11 at 9: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. – rakaz Feb 11 at 9:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.