Prefetch path works in production, not in development

Posts   
 
    
JayBee
User
Posts: 280
Joined: 28-Dec-2006
# Posted on: 29-Mar-2022 19:36:00   

I am on LLBLGen 4.2, self servicing,developping for dotnet 4.5.2. I run LLBLGen 5.3.8 on the same development machine. I am using Visual Studio 2019.

I have made an copy of the production database (SQL Server 2008R2) to my development database (SQL Server 2014) I am working on a webforms project (old style) using the dll's I have I am using in production. Testing the webforms site doing exactly the same in a part of the site I have not changed, I get the following error:

         The prefetch path element at index 0 in the passed in prefetch path for root entity type 10 is meant for root entity type 14 which isn't a subtype of 10. This
         means that you've added a prefetch path node to a Path of an unrelated entity, for example adding OrderDetailsEntity.PrefetchPathProduct to a prefetch path 
         for CustomerEntity.

I do not get this error in production, it works fine. What could be the issue?

This is the code:

        PickOrderDetailCollection pdc = new PickOrderDetailCollection();
        PredicateExpression filter = new PredicateExpression(PickOrderDetailFields.IdPickOrder == order.Id);
        PrefetchPath prefetch = new PrefetchPath((int)EntityType.PickOrderDetailEntity);
        prefetch.Add(PickOrderDetailEntity.PrefetchPathArticle);
        RelationCollection relationToUse = new RelationCollection(PickOrderDetailEntity.Relations.ArticleEntityUsingIdArticle);
        SortExpression sorter = new SortExpression(ArticleFields.InternalCode | SortOperator.Ascending);
        pdc.GetMulti(filter, 0, sorter, relationToUse, prefetch);
JayBee
User
Posts: 280
Joined: 28-Dec-2006
# Posted on: 29-Mar-2022 20:34:08   

In the website a report is being produced when the error is given. I isolated the part that is giving a problem and it works properly when I generate the same report via a console program. The error is confusing since the database itself is not causing the problem. It must be something else......

JayBee
User
Posts: 280
Joined: 28-Dec-2006
# Posted on: 29-Mar-2022 21:08:07   

The problem is solved. I cleaned the solution and regenerated against the dll's that are in production. It works fine now. We're upgrading several environments to the same level of OS and SQL Server. In this process we are also upgrading to dotnet 4.8 and making the databases on the different environments alike. So there will be a single dll for a certain set of tables and functionality. Tables that are not relevant in an environment will still be defined, just to have te same dll's on all environments. This is probably where something went wrong. A new dll created against out uniformal database was probably still here whereas all the relations / foreign keys were not yet added.

JayBee
User
Posts: 280
Joined: 28-Dec-2006
# Posted on: 29-Mar-2022 22:34:46   

I know what the problem was. I have opened the llblgenproj file with version 5.3.8. That changes the content of the file. When I reloaded it with 4.2 that seemed to work alright but apparently some definition settings or creation settings related to foreign keys and prefetch paths was changed. The 4.2 version of LLBLGen as a result of this did not generate the code.

From a backup I deleted all generated code with the exception of the visual studio project file, I copied the llblgenproj file from a previous version (2016..), synced it with the database ,reengineered the missing definitions and generated the code. All in LLBLGen 4.2. After that, everything was fine.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 30-Mar-2022 09:27:35   

Glad you solved it! simple_smile Formats of the llblgenproj files are in general the same, but settings are often not the same. forward compatibility works but loading a file from a newer version into an older version can lead to problems.

Frans Bouma | Lead developer LLBLGen Pro