LazyLoading is not working

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
christian_bertram
Posts: 16
Joined: Mon 22 Jun 2015 08:38

LazyLoading is not working

Post by christian_bertram » Tue 06 Oct 2015 14:33

I have a problem with the lazy loading functionality of EF6. I want tu use it (loading by "Include()") but it just doesn´t work.
Everything i tryed had absolutely no effect and i cant figure out why.

I have tryed following approaches:

changing the edmx xml:

Code: Select all

<EntityContainer Name="MyEntitiesContext" annotation:LazyLoadingEnabled="false">
setting the lazyloadingenabled attribute:

Code: Select all

public MyEntitiesContext() : base("name=MyEntitiesContext", "MyEntitiesContext")
{
    this.ContextOptions.LazyLoadingEnabled = false;
    OnContextCreated();
}
setting the attribute right before using the context:

Code: Select all

    context.Configuration.ProxyCreationEnabled = false;
    context.Configuration.LazyLoadingEnabled = false;
i even added set the SerializerSetting for web api:

Code: Select all

public static void Register(HttpConfiguration config){
config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
}
Nothing helps, the navigation properties of my entities are still created. During debugging i can navigate deeper and deeper and my application crashes during serialization to json.

The only possible way is to delete the navigation properties in my edmx model (database first) but thats not a solution because of course i want to use my entites without manually combining them.


Any solution? :(

I´m using .net 4.6, Ef6, the newest dotconnect and database first. (i'm creating a dll with the context in one project and use it in my web application)

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: LazyLoading is not working

Post by Shalex » Thu 08 Oct 2015 07:15

Please try the sample described at http://forums.devart.com/viewtopic.php?t=20908. It works in our environment, tested both ways:
a) context.ContextOptions.LazyLoadingEnabled = false;
b) <EntityContainer Name="MyEntities" annotation:LazyLoadingEnabled="false" ...>

JIC: Lazy Loading is a feature of Entity Framework engine (no support in provider is required).

christian_bertram
Posts: 16
Joined: Mon 22 Jun 2015 08:38

Re: LazyLoading is not working

Post by christian_bertram » Fri 16 Oct 2015 14:27

Hi, the configuration finally works for me but i still dont have a clue why it did not work.
I created a new EDMX model. Maybe tthere was a problem with it.

Post Reply