Skip to content Skip to sidebar Skip to footer

Entity Framework, SQLite And Lazy Loading

Hi I had developed a C# Budget application using SQL Compact and EF4, I created the EF model through the VS2010 Entity Data Model template. It is all working very well. However I a

Solution 1:

In second example your code snippet begins with:

var accoutTypes = budget.BankAccountTypes;

This loads all bank account types to your application and you don't need lazy loading anymore (EF will automatically recognize that these entities were already loaded and fix relations with bank accounts).

First check if your account class is dynamic proxy (just check type of a in the debugger). If it is not you made some mistake in the class definition and lazy loading will not work. Next check if lazy loading is enabled on your context instance (budget.ContextOptions.LazyLoadingEnabled property).


Solution 2:

Make sure the BankAccountType property is declared virtual in BudgetEntities.


Post a Comment for "Entity Framework, SQLite And Lazy Loading"