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 created an entity from the following view:
CREATE VIEW [ReportBuilder].[PersonAffiliate] AS SELECT PersonRole.PersonId, AffiliatePerson.FirstName, AffiliatePerson.LastName, MetaData.PersonType.PersonTypeName AS Role FROM Community.PersonRelationship INNER JOIN Community.PersonRole AS AffiliatePersonRole ON Community.PersonRelationship.RelatesToPersonRoleId = AffiliatePersonRole.PersonRoleId INNER JOIN Community.Person AS AffiliatePerson ON AffiliatePersonRole.PersonId = AffiliatePerson.PersonId INNER JOIN Community.PersonRole AS PersonRole ON Community.PersonRelationship.PersonRoleId = PersonRole.PersonRoleId INNER JOIN MetaData.PersonType ON AffiliatePersonRole.PersonTypeId = MetaData.PersonType.PersonTypeId
In the model designer I set the Name to "RbPersonAffiliate" and the Identity Column Name to "PersonId". I then add a one to many association from my RbPerson entity to RbPersonAffiliate and set the Column Name to "PersonId". When I attempt to save I get the following error: Column PersonId is mapped multiple times in entity RbPersonAffiliate I don't understand why I'm getting that because I'm doing the exact same thing with several other view entities and it works properly. I think there might be a bug. Any ideas? |
|
|
The problem occurs because when you create your association, it creates three things in LightSpeed: the RbPersonAffiliates collection, the RbPerson backreference, and a RbPersonId foreign key field. By setting the column name on the association, you are asking LightSpeed to map the RbPersonId foreign key field to the PersonId column. But you have also asked LightSpeed to map the Id to the PersonId column. This will cause problems at runtime because LightSpeed can't map one column to two places, so the designer complains. If you want an association to use an existing property as its foreign key, rather than creating a foreign key field, then instead of Column Name you must use Key Property Reference. In this case the Key Property Reference would be Id because it refers to the LightSpeed property that contains the FK, not the FK column in the database. |
|
|
Thanks Ivan. Setting the Key Property Reference to "Id" fixed it for me. |
|