Changing visual designer to fluent: ORA-00904

6 posts, 1 answers
  1. Roel Abspoel
    Roel Abspoel avatar
    8 posts
    Member since:
    Nov 2008

    Posted 03 Oct Link to this post

    I am following (in a testproject) the instructions to change my project to use fluent instead of the visual designer as its no longer supported.

    However after following the steps i get an ORA-00904 error indicating: "ORA-00904: "B"."Id2": invalid ID"

    I am guessing it is tripping over a foreign key and it looks quite similair to the thread: http://www.telerik.com/forums/upgrade-adds-a-2-on-some-foreign-keys

    Any ideas on how to resolve this?

  2. Roel Abspoel
    Roel Abspoel avatar
    8 posts
    Member since:
    Nov 2008

    Posted 03 Oct in reply to Roel Abspoel Link to this post

    For clarity: None of the tables has a column named Id2 so it seems to be generated somehow.
  3. DevCraft banner
  4. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 05 Oct Link to this post

    Hi Roel,

    Thank you for contacting us.

    Could you provide me with the following additional details:
    1. Do you have any inheritance structures in you model (the types of inheritance supported by Data Access are described here)?
    2. After which step in the tutorial you receive the error?
    3. Could you provide the .rlinq file and the DDL script of the database for a review on our side?

    I'm looking forward to hearing from you.

    Regards,
    Doroteya
    Telerik by Progress
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  5. Roel Abspoel
    Roel Abspoel avatar
    8 posts
    Member since:
    Nov 2008

    Posted 05 Oct in reply to Doroteya Link to this post

    Hi and thank you for your reply,

    What i did was create a new project and from the VS telerik menu choose: Add Domain Model. Then i would add two classes like: Person and Adres. In Adres i would define a field: PersonId and reference it to the person class.

     

    Then when i access the data all would be fine and i would start converting it using the logic from this post. I would change the mapping type to Fluent; copy and include the specified files, add the fluent assembly's from the package manager.

    When i rebuild and access the data i get the oracle error.

     

    I have an example project with a unittest to create/retrieve data. I have included both the project before attempting the conversion to fluent (error free) and after (produces an error when running the test)

    Im unfamiliar with the term in your first question so I cant answer that really; however the problem seems to be in the foreign key where a column name is changed to Id2 instead of Id or PersonId. 

    I get the error after following the steps in the mentioned post. (no compile errors, just a runtime oracle error)

    the .rlinq (and everything else) is in the mentioned projects.

  6. Answer
    Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 07 Oct Link to this post

    Hi Roel,

    Thank you for the additional details.

    The reason for the error is that the foreign key constraint between the two classes is missing in the model. The solution is to modify a bit PrepareAdresAssociationConfigurations() using the HasConstraint() method. Without this enhancement Data Access is unable to resolve which of the Adres properties is the foreign key. Thus it defaults to Default Mapping and adds in the metadata model the Id2 column as a foreign key property.

    The PrepareAdresAssociationConfigurations() method should look like this:
    1.public void PrepareAdresAssociationConfigurations(MappingConfiguration<Adres> configuration)
    2.{
    3.    configuration.HasAssociation(x => x.Person)
    4.        .HasFieldName("_person")
    5.        .WithOpposite(x => x.Adres)
    6.        .HasConstraint((x, y) => x.PersonId == y.Id)
    7.        .WithDataAccessKind(DataAccessKind.ReadWrite);
    8.}

    The conversion between the .rlinq file and the fluent model did not generated it for two reasons:
    - it was not defined in the .rlinq file
    - the persistent classes were not mapped to tables in .rlinq file.

    I hope this helps.

    Regards,
    Doroteya
    Telerik by Progress
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  7. Roel Abspoel
    Roel Abspoel avatar
    8 posts
    Member since:
    Nov 2008

    Posted 07 Oct in reply to Doroteya Link to this post

    Hello Doroteya,

    Thank you for the research and clarification. Adding the HasConstraint indeed fixed the problem for me and the project now runs as expected.

    Kind regards,

    Roel

Back to Top
DevCraft banner