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 using LS3 and trying to set up a one-to-many association between a product master and its transactions for an existing database. In the model I have used the same name, ProductId, for the primary key of the master and the foreign key in the transactions (since this is the way it is int he database). I get an error in the generated code for the transactions class saying the ProductId is defined twice. The only way I can eliminate the errors is to name the foreign key property differently. Is this limitation on key names a design constraint in LS or is this just a bug? Thanks |
|
|
In a LightSpeed entity, the primary key (identity) is always named Id, and the Id property is defined in the Entity<T> base class: you don't need to create your own identifier field in the designer. What you need to do instead is tell LightSpeed to map the Id property to the ProductId database column. To do this, select the entity, go to the Properties window and set the Identity Column Name. Conversely, on the Transaction class side, when you set up the Product association, the designer automatically generates a ProductId foreign key field. You don't need to create a ProductId field yourself, and if you do, you will indeed get this duplication error. Just remove the manually created ProductId field, and let the automatic one take over. |
|
|
I understand. Slick. Thanks. |
|