Lazy Loading not enabled in the CSDL

Posts   
 
    
cjbiggs
User
Posts: 64
Joined: 17-Apr-2009
# Posted on: 29-Jun-2011 06:37:43   

Using LLBLGEN 3.1 (June 17, 2011) and PostgresSQL 8.4.1.

Generating Code using the EFv1 (EFv4) template with the LazyLoading enable does not set the namespace and annotation in the CSDL of the EDMX file. This forces my application to use the .Include to load the navigated properties of my Entities (Eager Loading). See output of code generation and expected code generation.

Here’s what they should have to enable lazy loading:

<edmx:ConceptualModels>

<Schema Namespace="SSCSJournalModel" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">

<EntityContainer Name="SSCSJournalEntities" annotation:LazyLoadingEnabled="true">

Here’s what they did have:

                            <edmx:ConceptualModels>

                                            <Schema Namespace="SSCSJournalModel" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">

                                                            <EntityContainer Name="SSCSJournalEntities">

Thanks,

Charlie J.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 29-Jun-2011 09:35:57   

Lazy loading is enabled on the context level in the generated context class (context.ContextOptions.LazyLoadingEnabled). To my knowledge it's not necessary to add an annotation for it in the edmx. You can switch on/off lazy loading on the project through a setting in the project: open project properties -> Output setting values -> EnableLazyLoadingOnContext. Check the check box -> OK -> regenerate code.

Frans Bouma | Lead developer LLBLGen Pro
cjbiggs
User
Posts: 64
Joined: 17-Apr-2009
# Posted on: 29-Jun-2011 15:38:44   

Thanks Otis. We are not using the generated context. We use the LLBLGEN Designer to generate the EDMX and only take the EDMX file and drop it into our Application Project and Visual Studio regenerate from the EDMX file. So the namespace and annotation attributes are needed in the EDMX file. We did a test by manually adding it to the EDMX and it worked just fine.

Thanks,

Charlie J.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 29-Jun-2011 16:50:59   

The problem I have is that the annotation attribute is in the EDMX, for everyone. So if we generate it into the EDMX, based on the setting, it's in the EDMX as annotation, and it's unclear to us if this annotation takes precedence over context.ContextOptions' setting (as there's 0.0 documentation about which annotations you can use in edmx).

I.o.w.: if someone enables it in the settings, and it's in the edmx, s/he can't disable it in the code anymore... or at least, that's unclear.

As you're generating the context anyway, why not generate lazyloading enabled (it's enabled by default in EF anyway) into the context class you're generating?

Frans Bouma | Lead developer LLBLGen Pro
cjbiggs
User
Posts: 64
Joined: 17-Apr-2009
# Posted on: 30-Jun-2011 21:50:11   

If I drop the EDMX file that the LLBLGEN Designer generated into my an application I created, it generates the EDMXFileName.Designer.cs. The EDMX Generated by LLBLGEN cannot be viewed in Visual Studio 2010 to set the LazyLoading on the model using the Microsoft Designer. Are you saying put it the Context constructor?

Thanks,

Charlie J.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 30-Jun-2011 22:11:19   

What happens when you try to view the LLBLGen EDMX file in visual studio ? It should work fine.

Matt

cjbiggs
User
Posts: 64
Joined: 17-Apr-2009
# Posted on: 01-Jul-2011 07:12:09   

It says that it is unable to view it in the Model View and I have to view it in the XML View.

Thanks,

Charlie J.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 01-Jul-2011 10:57:29   
cjbiggs
User
Posts: 64
Joined: 17-Apr-2009
# Posted on: 05-Jul-2011 16:26:14   

I am still not able to open the EDMX file in the EF Designer after setting the Custom Tool = EntityModelCodeGenerator as the link suggest that I do. So if I can't open the EDMX to set the LazyLoading flag, then I guess I have to do it in the constructor of the context right?

Thanks,

Charlie J.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 05-Jul-2011 17:39:26   

Yes.

It won't allow you to open the file in ef's own designer because entity design info is missing (obviously). This is a good thing though, as the default EF designer would otherwise generate new code which you then have to remove manually again...

Frans Bouma | Lead developer LLBLGen Pro