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
|
Hi, I've got a bit of a porblem straight of the bat. I dragged a couple of tables into the Model. The tables are a portion of a solution relating to Scheduling. One table "AppTimes" has SharedAppID and this column is referenced from many tables. In the picture below I have illustrated a simple scenario with Multiple Customers & Multiple Resources sharing the one AppTime using SharedAppID as the primary/foreign key to establish the relationships and referential integrity:
As you can see I get the error: Entity <dbTable> has multiple properties/associations named <dBcolumn> 1. Does LightSpeed support the above dB schema?
2. How would I go about debugging an error in the model?
Cheers, Jeremy |
|
|
fyi: I did see this post: http://www.mindscape.co.nz/forums/Thread.aspx?PostID=3138 "Multiple Self References" but I think my issue is different as I'm trying to get two Entities referencing one Entity via one property, rather than the self referencing scenario described in the link above. Sure I could have multple SharedAppID columns with different names, but that isn't a elegant solution and I've been handed this legacy dB and code base and am trying to fix it up not pollute it more. Suggestions and solutions much appreciated? ps I saw in thw other post the guy could see the source and work out the problem. But I cant even save the Model due to the error to see generated code, so how did he (debug it)? Cheers, Jeremy |
|
|
Hi Jeremy, Check the name on your associations (which are squished out of view in the screenshot). For example, if LightSpeed infers a property (lets say "SharedApp") and an association as being called "SharedApp" then it will generate them that way but fail validation like you see there. LightSpeed doesn't do the annoying thing of calling one SharedApp1, the next SharedApp2, etc etc because we think you'll want the right name from the start :-) Make sure your association names are unique and do not match the names of your properties - remember that an entity AND its associations collapse into a single C# class so the names cannot be the same as it would mean you're defining two fields and properties with the same name. So that should help - you can change the name on the design surface and you'll be good to go. Let me know if this doesn't help you out. John-Daniel Trask |
|
|
Hi JD, Sweet as, I'll let you guys know if I have any further Q's. Here's a screenshot for other people facing the same issue: The Fix: Cheers Jeremy |
|
|
Are you saying that SharedAppID is both the primary key and a foreign key? LightSpeed doesn't directly support that scenario because LightSpeed expects to be able to allocate its own IDs (primary keys) -- it can be done but requires a bit of code. Let me know if this is the case and you want more info. LightSpeed *does* support many tables having FKs to the same PK (SharedAppID); these will result in associations named SharedApp on the other entity classes, though, not on TblAppTime, which doesn't cause a name conflict. For debugging the model, the error message already indicates the problem, so it is just a matter of locating the specific properties/associations and deciding how to resolve the problem. For locating the specific properties/associations, the best thing to do is expand the diagram (drag things around) a bit so you can see all the associations on TblAppTime (the names appear on the association arrows). That will allow you to see where the name SharedApp is appearing. You can then decide how to resolve it, typically by renaming one of the occurrences. (You will probably need to set the Column Name of the renamed property or the Backreference Column Name of the renamed association, so that the new name continues to map to the "old name" in the database.) |
|
|
Oops, notification FAIL. Didn't see you'd already resolved this. Ignore previous message *grin*. |
|