Entity Factories not being generated

Posts   
 
    
clint
User
Posts: 150
Joined: 15-Nov-2005
# Posted on: 18-Nov-2009 23:08:22   

LLBLGen Pro Version 2.6 Final (April 15th, 2009) Adapter Template, .Net 2.0

I added some new tables to my database. This is the first time I've done that since upgrading to LLBLGen 2.6. I refreshed the catalog and generated the code. But some of the generated code won't compile because they refer to entity factories that don't exist in EntityFactories.cs. How come no entity factories were generated for my new tables?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Nov-2009 05:24:56   

Could you please post the compile error you received? I think it should be the opposite: some entities classes files listed in entity factories are missing.

If my guess is correct, you have two options:

  1. Set this flag to true and generate code again (ref...):

CleanUpVsNetProjects When set to true, the VS.NET project file task performer will first remove all file references for files from an existing VS.NET project file, before adding the files generated. For VS.NET 2005 projects, it will remove all files generated by LLBLGen Pro, as these are marked with a Generator tag.

Note: Use with care as an old VS.NET project may contain references to files which aren't marked with LLBLGen Pro specific XML elements/attributes, so all file references are removed, which thus also means that references to files you've added yourself to the project are removed as well, which forces you to re-add the references to those files to the VS.NET project manually. Projects created for VS.NET 2005 and with LLBLGen Pro v2.0 or higher do have the files marked as LLBLGen Pro generated and it's safe to use this setting with these projects.

  1. Add the files manually. Look at the EntityClasses folder of you DBGeneric project. There you will figure out that some entities are missing (your new ones), but they exist in file system, so add them manually.
David Elizondo | LLBLGen Support Team
clint
User
Posts: 150
Joined: 15-Nov-2005
# Posted on: 19-Nov-2009 16:24:04   

daelmo, thanks for the response.

daelmo wrote:

Could you please post the compile error you received? I think it should be the opposite: some entities classes files listed in entity factories are missing.

The entity classes show up in the Visual Studio Solution Explorer. There just isn't a corresponding factory for it in EntityFactories.cs

Here is one example of the type of errors I'm getting.

Description: The type or namespace name 'DataExchangePartnerRecentExportEntityFactory' could not be found (are you missing a using directive or an assembly reference?) File: DataExchangePartnerEntity.cs

Below is the code that caused that error. It gets an error on the line that references DataExchangePartnerRecentExportEntityFactory.


/// <summary> Gets the EntityCollection with the related entities of type 'DataExchangePartnerRecentExportEntity' which are related to this entity via a relation of type '1:n'.
/// If the EntityCollection hasn't been fetched yet, the collection returned will be empty.</summary>
[TypeContainedAttribute(typeof(DataExchangePartnerRecentExportEntity))]
public virtual EntityCollection<DataExchangePartnerRecentExportEntity> DataExchangePartnerRecentExport
{
    get
    {
        if(_dataExchangePartnerRecentExport==null)
        {
            _dataExchangePartnerRecentExport = new EntityCollection<DataExchangePartnerRecentExportEntity>(EntityFactoryCache2.GetEntityFactory(typeof(DataExchangePartnerRecentExportEntityFactory)));
            _dataExchangePartnerRecentExport.SetContainingEntityInfo(this, "DataExchangePartner");
        }
        return _dataExchangePartnerRecentExport;
    }
}

clint
User
Posts: 150
Joined: 15-Nov-2005
# Posted on: 19-Nov-2009 21:36:34   

I found a workaround for my problem.

Since LLBLGen wasn't updating my existing EntityFactories.cs file (it did update the change date, but that's all), I generated the project again but directed the output to a new folder so it would create new files. The new EntityFactories.cs file had the new factories. So I used that instead.

However, I'd still like to know why LLBLGen wouldn't add those new factories to my existing EntityFactories.cs file.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-Nov-2009 04:31:16   

However, I'd still like to know why LLBLGen wouldn't add those new factories to my existing EntityFactories.cs file.

It should work as expected. The generation to a empty folder is indeed a workaround for edge cases. Maybe your file was under source-control so this was read-only, or maybe you changed the target folder names. As I can't reproduce that, I don't know what caused this, but if you can listed some steps to reproduce it (Do you can reproduce it again?) we will try to answer your question.

David Elizondo | LLBLGen Support Team
clint
User
Posts: 150
Joined: 15-Nov-2005
# Posted on: 03-Dec-2009 19:57:13   

daelmo wrote:

However, I'd still like to know why LLBLGen wouldn't add those new factories to my existing EntityFactories.cs file.

It should work as expected. The generation to a empty folder is indeed a workaround for edge cases. Maybe your file was under source-control so this was read-only, or maybe you changed the target folder names. As I can't reproduce that, I don't know what caused this, but if you can listed some steps to reproduce it (Do you can reproduce it again?) we will try to answer your question.

I haven't tried reproducing the problem and probably don't have time to try. So I'll consider this thread closed.

Thanks.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 03-Dec-2009 21:10:47   

Ok Thanks.

Your issue is almost always caused by the file being marked as read-only or in some other way locked - it's a question we answer about twice a month...simple_smile

Matt