One to one association issues

Thread is closed for posting
1 posts, 0 answers
  1. Dilshod
    Dilshod avatar
    28 posts
    Member since:
    Feb 2012

    Posted 15 Dec 2016 Link to this post


    In my model I was using one to many associations until recently  and now decided to use one to one associations. Once I added a one to one relationship between two tables it builds fine, but when I run it, it throws exception: Exception thrown: 'System.InvalidCastException' in Telerik.OpenAccess.Runtime.dll
    Additional information: Unable to cast object of type 'Model.Entities.SAPassport' to type 'OpenAccessRuntime.common.OID'.

    I will try to explain my model here. I have a Student entity and it has many other one to many associations. I recently added a new entity called Passport and relationship between student and passport is one to one(Both of their PrimaryKey fields have the same value because of one to one relationship). In my code I am creating a Passport and Student. Both of their Id fields has the same value. But when I save I get the exception above.

    Then I tried with really simple entities. I created Person entity and PersonInfo and made a one to one relationship between them. There are no more associations to these entities or from these entities. When I create these entities and set their IDs as the same and save I don't get any exceptions.

    My question is, why there is an exception in the first use case? And what does that exception mean? There is no documentation about it.



    Dilshod Niyozov

Back to Top