EF Core Code Generation ignoring field order

Posts   
 
    
TL66
User
Posts: 5
Joined: 04-Dec-2020
# Posted on: 04-Dec-2020 18:04:33   

Using latest LLBLGen Pro 5.7 It is my preference to keep the order of field in the generated entities the same as in the database.

Using LLBLGen Pro runtime this works as expected. However, when targeting EF core 3.0, the generated entities are always generated alphabetically.

In the designer, the field order has been specified, the fields are ordered in the designer as I expect.

Is this a shortcoming of the EF Core code generation templates, or should this be working, and I have missed something.

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 05-Dec-2020 10:49:38   

I indeed see the ordering is alphabetical. It doesn't really matter in which order the fields are stored for runtime functionality, you have a specific reason for requiring the fields in a given order in the generated poco class? We generate them alphabetically to make merging code easier in source control

Frans Bouma | Lead developer LLBLGen Pro
TL66
User
Posts: 5
Joined: 04-Dec-2020
# Posted on: 07-Dec-2020 00:41:15   

Otis wrote:

I indeed see the ordering is alphabetical. It doesn't really matter in which order the fields are stored for runtime functionality, you have a specific reason for requiring the fields in a given order in the generated poco class? We generate them alphabetically to make merging code easier in source control

Sometimes when working, it is useful when us humans when, for example looking for the field you missed in an initializer. For this type of exercise - having field in the same order is very useful. I use it often enough that it is my strong preference. I tend to intentionally group related fields together in terms of field order, so they are visually presented together.

As for merging - the most important aspect is the consistency - not alphabetical - (although alphabetical is a form of consistency). And if using the database field order in the designer ( as I usually do), then changes in POCO class usually end up at the end of the list of fields - another useful consistency when looking at code history.

I fully accept that in terms of machine functionality, does not matter - but when us humans are looking at code / objects, picking the order that works for us is useful.

Is there a technical reason why this was left of of .net core template - or is it just simply not implemented yet?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 07-Dec-2020 09:56:20   

It's simply not implemented in the template. It's not a big change. We'll add it for v5.8.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Jan-2021 13:47:30   

Implemented in v5.8

Frans Bouma | Lead developer LLBLGen Pro
TL66
User
Posts: 5
Joined: 04-Dec-2020
# Posted on: 20-Jan-2021 14:43:00   

Otis wrote:

Implemented in v5.8

Excellent! Look forward to trying it out when it is released.