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

Beginner: Trouble With Associations

2 Answers 58 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kurt
Top achievements
Rank 1
Kurt asked on 23 Jan 2014, 08:18 PM
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 Answers, 1 is accepted

Sort by
0
Kurt
Top achievements
Rank 1
answered on 25 Jan 2014, 10:00 PM
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
0
Boyan
Telerik team
answered on 27 Jan 2014, 02:42 PM
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. 

Regards,
Boyan
Telerik
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!
Tags
Data Access Free Edition
Asked by
Kurt
Top achievements
Rank 1
Answers by
Kurt
Top achievements
Rank 1
Boyan
Telerik team
Share this question
or