The field name 'ColumnName1' isn't known in the element 'TableName1Entity'

Posts   
 
    
rot
User
Posts: 5
Joined: 13-Dec-2011
# Posted on: 13-Dec-2011 15:55:44   

Can someone explain to me what this exception means and maybe how to solve it:

System.ArgumentException was unhandled by user code Message=The field name 'ColumnName1' isn't known in the element 'TableName1Entity' Parameter name: fieldName Source=SD.LLBLGen.Pro.ORMSupportClasses.NET20 ParamName=fieldName StackTrace: at SD.LLBLGen.Pro.ORMSupportClasses.PersistenceInfoProviderBase.GetFieldPersistenceInfo(String elementName, String fieldName) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.GetFieldPersistenceInfo(IEntityField2 field) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.GetFieldPersistenceInfos(IEntityFields2 fields) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollectionInternal(IEntityCollection2 collectionToFill, IRelationPredicateBucket& filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection(IEntityCollection2 collectionToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath2 prefetchPath, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection(IEntityCollection2 collectionToFill, IRelationPredicateBucket filterBucket, IPrefetchPath2 prefetchPath) ...

The code that thorws the exception:

using (IDataAccessAdapter adapter = AdapterXxFactory.GetDataAccessAdapter())
{
    EntityCollection collection = CreateCollection();
    collection.Clear();
    adapter.FetchEntityCollection(collection, null, null); //<-- Exception thrown here
    ...
}

LLBLGenPro 3.0 Final

Thanks in advance... Best regards.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 13-Dec-2011 21:10:24   

What is CreateCollection(); ?

Ideally, a fetch routine looks like this:

using (IDataAccessAdapter adapter = AdapterXxFactory.GetDataAccessAdapter())
{
    EntityCollection<MyEntity> collection = new EntityCollection<MyEntity>();
    collection.Clear();
    adapter.FetchEntityCollection(collection, null, null);
    ...
}
David Elizondo | LLBLGen Support Team
rot
User
Posts: 5
Joined: 13-Dec-2011
# Posted on: 13-Dec-2011 22:45:59   

Thanks for you reponse!

daelmo wrote:

What is CreateCollection(); ?

If I inline the CreateCollection method the code looks like this:

using (IDataAccessAdapter adapter = AdapterXxFactory.GetDataAccessAdapter())
{
    EntityCollection collection = new EntityCollection(new MyTableName1EntityFactory());
    collection.Clear();
    adapter.FetchEntityCollection(collection, null, null); //<-- Exception thrown here
    ...
}

A bit of background: This is old code (from before generics existed) that worked until I added ColumnName1 to TableName1 in the database and regenerated the DAL layer with LlblGenPro.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 14-Dec-2011 05:15:08   

What occurs to me is that your connectionString is pointing to a database that doesn't have that change (the new column). So the select query is including your new column but it is not in your database. Please check that.

David Elizondo | LLBLGen Support Team
rot
User
Posts: 5
Joined: 13-Dec-2011
# Posted on: 14-Dec-2011 09:23:25   

daelmo wrote:

What occurs to me is that your connectionString is pointing to a database that doesn't have that change (the new column). So the select query is including your new column but it is not in your database. Please check that.

I have checked again that the connection string is set correctly.

And when I set it to a database that does not exists I get the same exception. confused

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 14-Dec-2011 10:02:54   

Might be that your application is not using the latest generated DAL code.

rot
User
Posts: 5
Joined: 13-Dec-2011
# Posted on: 14-Dec-2011 10:53:31   

Problem solved. I’m new to LLBLGenPro and learned something today: simple_smile

1) LLBLGenPro generates not one but three projects (DataAccess, DataAccess.SQLJobs, and DataAccessDBSpecific). All of them have to be writeable (checked out of the source control system).

2) When LLBLGen has generated the source code it shows a status window. This window does not explicit show you if there are any errors. You have to scroll through all the messages (you can remove some of them by unchecking “Show normal messages”).