MS Access - Inheritied Entities - Primary Keys

Posts   
 
    
mshe
User
Posts: 167
Joined: 02-Feb-2006
# Posted on: 28-May-2007 14:21:12   

Is this normal - When I create inheritied entities with an Access database (Self Servicing, Target Per Entity), I have 2 PKs - the Parent Table AND Child Tables PK.

For example:

My Parent Parent_PK - Replication ID Field 1 Field 2

My Child Table Child_PK - ReplicationID Child_Field1 Child_Field2

My Generated Child Entity Looks Like Parent_PK - Replication ID Field 1 Field 2 Child_PK - ReplicationID Child_Field1 Child_Field2

When I last used inheritied entities in SQL Server, I believe the Parent's table PK is hidden when an entity is created? So basically should both PKs be shown? Is there a way to hide one PK (to avoid confusion).

Thanks!

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 28-May-2007 15:15:43   

Hello,

what version of llblgen do you use?

If you want the child table to inherit with the same id, you need to define Child_PK as a PK/FK key.

mshe
User
Posts: 167
Joined: 02-Feb-2006
# Posted on: 28-May-2007 15:26:41   

jbb wrote:

Hello,

what version of llblgen do you use?

If you want the child table to inherit with the same id, you need to define Child_PK as a PK/FK key.

Ya I did - v2.0 March 19th Build.

Turns out in LLBLGen designer, if I rename the child PK to the parent PK's name - it'll only generate 1 PK field.

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 28-May-2007 15:45:36   

Hello,

You have this problem only with access,If you try to generate the same code for sql server, do you have the same problem? could you please attach the lgp project file?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39914
Joined: 17-Aug-2003
# Posted on: 29-May-2007 10:56:31   

As they have different names, both fields are there. At runtime however they're linked to eachother, so setting one will set the other and vice versa. To have just 1 field, you have to give both PK fields in the entities (doesn't have to be in the db) the same name so the childpk overrides the parent's pk.

Frans Bouma | Lead developer LLBLGen Pro
mshe
User
Posts: 167
Joined: 02-Feb-2006
# Posted on: 29-May-2007 16:54:42   

Otis wrote:

As they have different names, both fields are there. At runtime however they're linked to eachother, so setting one will set the other and vice versa. To have just 1 field, you have to give both PK fields in the entities (doesn't have to be in the db) the same name so the childpk overrides the parent's pk.

Thanks for the clarification! Just wanted to make sure that was the intended behaviour.