This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have a table containing column UserId I have a second table containing two columns that refer to UserId in the first table Lightspeed does not like this, and says that column UserId is mapped multiple times.
how do I deal with this? I must have both columns referring to UserId |
|
|
never mind. I solved this by adding a separate Id column... one of the UserId references was part of a composite primary key. are there any plans to support composite primary keys of which one or more parts is also a foreign key? |
|
|
Yes, you can do this using ForeignKeyFieldAttribute (in code) or Key Property Reference (in the designer). See: http://www.mindscapehq.com/blog/index.php/2010/06/17/many-to-many-associations-and-composite-keys-in-lightspeed/ (it's written about many-to-many associations but the bits about one-to-many associations still apply to your case). |
|
|
is there a way to do this in the designer, or do I need to edit code to make it work? |
|
|
Yes, you can do this in the designer. Choose the one-to-many association arrow and edit its Key Property Reference setting (to refer to the PK component). See the second screenshot in the blog post linked above. |
|
|
I'm a little confused about why it can't set the key property reference automatically. Can't it detect that there's a composite key and handle it accordingly? obviously it's going to throw errors if these properties aren't set on composite keys, so it seems to me that it should happen automatically. |
|
|
Yes, we would like to implement auto-detection of foreign-composite keys, but for various reasons it's a bit complicated and we haven't yet been able to devote the time to it. It is definitely on the wish list though! |
|