Cannot reuse field name in quick mode

Posts   
 
    
JHolliday
User
Posts: 19
Joined: 22-Jun-2017
# Posted on: 22-Jun-2017 02:23:34   

In Quick Mode, I want to create a many-to-many mapping M between two entities A and B. I start by entering the following lines:

M.aKey 11 A.id M.bKey 11 B.id

Now, I want to create a new entity Z with a one-to-many relationship with A:

Z.aKey 1n A.id

This creates a new Z entity, but throws an error: "Invalid field name specified: 'The name 'Id' is already in use by a field, navigator or other element.'

What am I missing?disappointed

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 22-Jun-2017 16:20:29   

A.id has to be a PK field.

Please do:

A.id * B.id *

then do

Z.aKey 1n A.id

simple_smile

Frans Bouma | Lead developer LLBLGen Pro
JHolliday
User
Posts: 19
Joined: 22-Jun-2017
# Posted on: 22-Jun-2017 21:03:32   

Entering A.Id *, produces the following error:

"Invalid field name specified: 'The name 'Id' is already in use by a field, navigator or other element.'

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 23-Jun-2017 09:07:25   

Ahhh I see what's wrong simple_smile

I tried to reproduce what you were experiencing by going through your first post.

So I typed: A<enter> B<enter> which gave me two entities

Then I typed: M.aKey 11 A.id

and no fields appeared and then I realized I totally missed that 'aKey' and 'id' are navigators, not fields, like Customer.Order 11 Order.Customer. So then specifying 'id' as a field gives an error as it's not a field, but a navigator mapped onto the relationship like 'Orders' in Order.Customer m:1 Customer.Orders

To create relationships this way, you have to specify the navigators you want to use, not the fields, you specify the relationship between entities, not between fields.

For a m:n relationship in our designer, you need two m:1 relationships btw, not two 1:1 relationships. If you just want to define the two 1:1 relationships and not a real m:n relationship over that, that's fine though, and I'll use that below:

Anyway, to fix it, please do: (first remove the existing entities to avoid name clashes with previous attempts)

M.A 11 A.M M.B 11 B.M

this gives two 1:1 relationships, but no entity fields. Then type: A.Id int *

which gives an int typed Id field in A and marks it as a PK field It will also create an FK field in M. In quickmodel with 1:1 relationships, the start entity is always the FK side.

Do the same with B: B.Id int * and it will create an int typed Id field in B too, mark it as PK and will create an Fk field in M for it too.

To mark the fields in M as PK do:

u M

which will move to the scope M. Then type: AId * BId *

which will make the fields in M both part of the PK.

Frans Bouma | Lead developer LLBLGen Pro