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’m a LightSpeed newbie jumping in at the deep end. I’m creating my model against a legacy database. It’s a biggie with over 80 tables. All is going OK except for an issue with a self-referencing table. I’d be grateful for some help with it… The table is named “Item”. It has: A primary key named “PKID”. A foreign key named “ParentItemID” – indicates this item is a child of another item. A foreign key named “NewParentItemID” – indicates this child item is going to be “moved” from one parent item to another. (This description isn't necessarily relevant to my question but is intended to explain the naming.) When I create the model from the database and attempt to save it, I receive the error “Column PkId is mapped multiple times in entity Item”. I’m not sure how to handle this. I’ve scanned the forums looking for clues but it’s still not clear. What should I be doing? Thanks |
|
|
I wonder if your PKID primary key is also a foreign key to some other table? If that is the case we may have inferred an association named Pk from which we would infer a separate foreign key field named PkId. (In LightSpeed, an association is backed by a foreign key field, which is typically not part of the primary key.)
If it is the 'primary key is also a foreign key' scenario, let me know and I'll talk you through how to handle this. Also, I am assuming that inheritance isn't in play -- if Item is part of an inheritance hierarchy, then you can get this error from multiple entities in the inheritance hierarchy mapping the PkId column to different fields -- but again this seems unlikely to be the case for you. |
|
|
Hi Ivan Thanks very much for such a quick response! You gave me the clues I needed and the issue is now resolved. I found the database had been set up incorrectly with a foreign key relationship of Item.PKID to Item.PKID. Removing this cleared up the problem. Cheers James |
|