This is a migrated thread and some comments may be shown as answers.

Retrieving an object where there is a composite primary key

8 Answers 287 Views
Design Time (Visual Designer & Tools)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jonathan
Top achievements
Rank 1
Jonathan asked on 27 Aug 2010, 10:11 AM
Hello,
I am trying to retrieve an object to allow me to update it but get the following error message:

Telerik.OpenAccess.Exceptions.MetadataException: The field 'appraisalAssignment' of class 'EMS.DAL.Appraisal' must use nested db-column extensions in a db-ref extension as the class 'EMS.DAL.AppraisalAssignment' has a composite primary key. --> EMSEntityContext/namespace[EMS.DAL]/class[Appraisal]/field[appraisalAssignment]/db-column

I am using the following to get an existing object:

 

StatisticalDatum updatedStats = ems.StatisticalData.Where(sd =>; sd.AppraisalId 
== stats.AppraisalId).First();

 

where all I am interested in updating this specific object.

However, the object with the composite primary key is AppraisalAssignment which has a 4 field key and the object relationship is:
AppraisalAssignment -> Appraisal -> StatisticalDatum.

I cannot see, from the domain model, how to create the nested db-column extensions as described in the error message and in any case, I don't have all the values of the composite primary key for AppraisalAssignment at this point in the code.

How am I able to get around this situation?

Regards,
Jonathan

8 Answers, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 30 Aug 2010, 02:03 PM
Hello Jonathan Simmons,

 Have you used the Domain Model wizard (.rlinq file) to generate the model or is it done via the old 'Forward mapping' wizard? I guess it is via the Domain Model wizard/rlinq file .
The error message you see actually indicates invalid mapping. Can you provide us the rlinq file (app.config file if you have used the old Forward mapping wizard) so that we can have a closer look at the mapping for the 'EMS.DAL.Appraisal' type.

Looking forward to resolving the issue.

Best wishes,
Ady
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jonathan
Top achievements
Rank 1
answered on 30 Aug 2010, 02:36 PM
Have moved this to a support ticket as I can only upload image files from the forum.
Regards,
Jonathan
0
Ady
Telerik team
answered on 02 Sep 2010, 02:37 PM
Hello Jonathan Simmons,

 Were you able to make further progresss with the mapping of the AppraisalAssignment reference field?

Do get back to us in case you need any assistance in doing that.

Regards,
Ady
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jonathan
Top achievements
Rank 1
answered on 02 Sep 2010, 02:44 PM
Hello Ady,
We have decided not to proceed using OpenAccess this database as there is a lot wrong with the database design anyway. If OA had worked without any bother (which it has in all our other projects), that would have been great but for the time being, I will continue to update the existing stored procedures and C# code any time there is a change to the table structure. Fortunately this does not happen too often!

Many thanks,
Jonathan
0
Johan
Top achievements
Rank 1
answered on 15 Sep 2010, 05:49 PM
Hello there!


I´ve got a similiar problem (I have not designed the database in question):

 
I am using a MySQL db with OA Express.

 --------------------------------------------------

The field x of class 'TelerikOpenAccess.y' must use nested db-column extensions in a db-ref extension as the class 'TelerikOpenAccess.z' has a composite primary key. --> MySqlEntities/namespace[TelerikOpenAccess]/class[y]/field[x]/db-column

I used the "already existing database" wizard.

Could the error be in the design of the database rather than OpenAccess?


Anyway, is there anyway I can resolve this?

Btw, I really like your OA express edition!

0
Ady
Telerik team
answered on 21 Sep 2010, 09:45 AM
Hello Johan,

  We are glad that you find the OpenAccess product good to use.
Sorry for this delayed reply. There seems to have been a problem with support system. I had replied a few days back. Apparantely the reply didn't get through.

This error occurs when there is a Foreign Key constraint to a destination table with a composite primary  key. The corresponding reference field (Association element in the domain model) that is generated might not be completely mapped (field 'x' in your case). The mapping for this association should have column mappings for each column in the FK constraint. Can  you select the association and verify the mapping in the 'Mapping details editor'?

Best wishes,
Ady
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jörg
Top achievements
Rank 1
answered on 15 Feb 2012, 11:46 AM
Hello.

I have the same problem:

The field '<value>' of class 'OpenAccessModel.Door' must use nested db-column extensions in a db-ref extension as the class 'OpenAccessModel.Sector' has a composite primary key. --> EntitiesModel/namespace[OpenAccessModel]/class[Door]/field[_sectors]/collection/db-link-table/db-value/db-column

I not sure how I can verify the mapping in the 'Mapping details editor'?
When I select the association in the diagram I cannot see something in the editor.

Best regards
Jörg
0
Ady
Telerik team
answered on 15 Feb 2012, 05:44 PM
Hello Jörg,

 Is it possible to send me your .rlinq file? I can have a look at the mapping for this particular field and fix it for you. This would be the fastet way to get it working for you.
The excpetion is thrown when you have a reference to a class that has a composite primary key and the mapping is incomplete - maybe not all foreign keys are mapped to a primary key on the opposite side.

All the best,
Ady
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Design Time (Visual Designer & Tools)
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Ady
Telerik team
Jonathan
Top achievements
Rank 1
Johan
Top achievements
Rank 1
Jörg
Top achievements
Rank 1
Share this question
or