Retrieving an object where there is a composite primary key

9 posts, 0 answers
  1. Jonathan Simmons
    Jonathan Simmons avatar
    108 posts
    Member since:
    Jun 2005

    Posted 27 Aug 2010 Link to this post

    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

  2. Ady
    Admin
    Ady avatar
    589 posts

    Posted 30 Aug 2010 Link to this post

    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
  3. DevCraft banner
  4. Jonathan Simmons
    Jonathan Simmons avatar
    108 posts
    Member since:
    Jun 2005

    Posted 30 Aug 2010 Link to this post

    Have moved this to a support ticket as I can only upload image files from the forum.
    Regards,
    Jonathan
  5. Ady
    Admin
    Ady avatar
    589 posts

    Posted 02 Sep 2010 Link to this post

    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
  6. Jonathan Simmons
    Jonathan Simmons avatar
    108 posts
    Member since:
    Jun 2005

    Posted 02 Sep 2010 Link to this post

    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
  7. Johan
    Johan avatar
    1 posts
    Member since:
    Jul 2010

    Posted 15 Sep 2010 Link to this post

    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!

  8. Ady
    Admin
    Ady avatar
    589 posts

    Posted 21 Sep 2010 Link to this post

    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
  9. Jörg
    Jörg avatar
    5 posts
    Member since:
    Feb 2012

    Posted 15 Feb 2012 Link to this post

    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
  10. Ady
    Admin
    Ady avatar
    589 posts

    Posted 15 Feb 2012 Link to this post

    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 >>
Back to Top
DevCraft banner