Beginner: Trouble With Associations

Thread is closed for posting
3 posts, 0 answers
  1. Kurt
    Kurt avatar
    3 posts
    Member since:
    Jan 2014

    Posted 23 Jan 2014 Link to this post

    I am having some trouble with my associations. I want a user model and a person model to have a one to one relationship. So I click the association tool, click the person model, then click the user model. For the source class I use the UserID, and for the target class I put the PersonID. Thats all fine. Now my trouble is what to do with the Identity Mechanism, on my first run I left both of them on default. Well default works fine until I try to add a second item to the database and I get an error sayings I cant use the same primaryId twice. So I try changing both of them to DatabaseServerCalculation then I get an error telling me that wont work cause the foreign key for person is being generated by the UserID. So now I try to just leave the UserId as DatabaseServerCalculated and the PersonId as default and I get this error.

    The statement has been terminated. ---> System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "ref_User_Personal_Info_Bank_User". The conflict occurred in database "MyBank2", table "dbo.Bank_User", column 'UserId'.
  2. Kurt
    Kurt avatar
    3 posts
    Member since:
    Jan 2014

    Posted 25 Jan 2014 in reply to Kurt Link to this post

    Never mind, think I got it sorted out. It seems backendcalculating one object and leaving the other default works out just fine.. The problem was in a whole other object model, I had it setup so my user object was one to one with my person object, but my person object was one to one with a address object, and soon as I got rid of that address object it all worked fine.  With a one to one object the parent object is generating the ID for the child object, but I guess it just gets confused when a parent object gives a id to a object that gives a id to another object.. I think... lol
  3. Boyan
    Boyan avatar
    100 posts

    Posted 27 Jan 2014 Link to this post

    Hi Kurt,

    I am glad to hear that you have resolved the issue you encountered. In fact this scenario - modelling three tables with one-to-one relationship between them is possible with our Association Editor. If you still have any troubles implementing it please let me know so I can provide you with more detailed explanation of the process.
    Should you have any further question please get back to us. 

    OpenAccess ORM Q3 2013 simplifies your model operations even further providing you with greater flexibility. Check out the list of new features shipped with our latest release!
Back to Top