v3.1 upgrade issue - sequence of entity constructor arguments changed

Posts   
 
    
hotchill avatar
hotchill
User
Posts: 180
Joined: 22-Jan-2007
# Posted on: 14-Jul-2011 02:08:50   

Hi.

I have a table called SPEntityUserRoleAssignment that has a PK consisting of three fields: EntityId, UserId and RoleId.

v3.1 changed the sequence of entity constructor arguments from that of v2.6 and this led to some issues there were hard to catch.

Now I need to go through all tables having multi-field-PK where two or more of the fields are of same type.

Thanks, Tore.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 14-Jul-2011 03:24:20   

If you want, you can set the field's order manually in the Designer before generate code. See this: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=18386&StartAtMessage=25&#107926

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 14-Jul-2011 11:00:54   

Also through refresh you can reset the field ordering through a setting, this is useful when you indeed start from nothing and want to have field ordering as they are in the db.

Frans Bouma | Lead developer LLBLGen Pro
hotchill avatar
hotchill
User
Posts: 180
Joined: 22-Jan-2007
# Posted on: 14-Jul-2011 17:54:16   

Ok, but the tool reset the ordering here without any warning to me I believe.

I have changed to using object initializers for these entities to avoid the same problem again.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 14-Jul-2011 18:33:51   

hotchill wrote:

Ok, but the tool reset the ordering here without any warning to me I believe.

You have two options to go back to v2.6 ordering: 1) do it automatically once, through a refresh. This is controlled by: ResetFieldOrderBasedOnTargetOrderAtRefresh. After the refresh, set this to false again. From then on you can use option 2)

2) do it manually by applying a field ordering to the entities which have a compound PK (the rest is not really interesting anyway for this particular issue). After that, set UseCustomFieldOrderingOnNewElements to true, so new entities etc get a field ordering set automatically to the order in which you specify the fields or when you reverse engineer new entities, they get the order of the target db element. To find the compound PK entities, use element search in the designer, select 'Entity' as searchable element and specify: return p.EntityModel.Vertices.Where(e=>e.IdentifyingFields.Count() > 1);

If you want to keep the model as-is, you can also change your own code to deal with the alphabetical ordering, and leave it as-is.

Frans Bouma | Lead developer LLBLGen Pro