Support for multiple associations on the same primitive member

4 posts, 0 answers
  1. Chris
    Chris avatar
    1 posts
    Member since:
    Mar 2008

    Posted 17 Aug 2012 Link to this post

    Hi

    We are currently evaluating OpenAccess as an ORM to use in our projects and have come across the following issue.

    We have a table called Security which has a large number of columns. We have split this table into three sql views (Security,SecurityCashFlow, SecurityCurrent). We have then mapped three entities one for each view. The following error occurs when trying to create the associations.


    “The primitive member 'SecurityId' used in foreign key association 'SecurityHasSecurityCashflow' is used in another association 'SecurityHasSecurityCurrent'. This setup is not supported by the OpenAccess runtime.”

    Security has a 0..1:1 association with both SecurityCashFlow and SecurityCurrent. The SecurityId field is the key for each of the entities.

    Is it possible in Open Access to have multiple associations to the same property? or is there another way to support this scenario?

    Thanks

    Chris

  2. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 17 Aug 2012 Link to this post

    Hi Chris,

    It is true that at the moment OpenAccess cannot handle more than one association based on the same foreign key member/column.

    However, I think there is a good solution for your case which avoids this limitation. As the three views share the same id column, this means that the associations between the three views are 1:1 and one object always has the other two on the other side, there is no case of a null reference. Having this in mind, it should not make a difference if you define the associations the other way around, where SecurityCashFlow and SecurityCurrent have the foreign keys and Security holds the primary key. You would get the same SecurityCashFlow and SecurityCurrent references in the Security class.

    So please just try dragging the associations in the opposite direction and let us know if you face further difficulties.

    Greetings,
    Alexander
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  3. DevCraft banner
  4. Swee Eng
    Swee Eng avatar
    3 posts
    Member since:
    Sep 2012

    Posted 24 Oct 2012 Link to this post

    Hi,

    I am facing the same issue in my usage of OpenAccess. The thing is I do not have liberty to change the database as I like, as the database is from a third party. So as such, there is no way I can go around the problem? So I should forsake using OpenAccess? Hope you can advise me on this. Thanks.

    Regards,
    Swee Eng
  5. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 29 Oct 2012 Link to this post

    Hello Swee Eng,

    Could you share some information about your database schema? What type of associations are present there? Please describe the setup that you are not able to map with OpenAccess, so we can reproduce it locally and try to find a solution for you.

    Regards,
    Alexander
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
Back to Top