Issue upgrading project to fluent - Invalid column name

Thread is closed for posting
2 posts, 0 answers
  1. AndrePereira
    AndrePereira avatar
    6 posts
    Member since:
    Apr 2015

    Posted 07 Aug 2017 Link to this post

    Hi,

    I was put on this project to perform an upgrade for the newer telerik version.

    One of the issues i have been trying with no success, is upgrading the data modeling to fluent.

     

    I followed, the the steps i found at http://www.telerik.com/blogs/benefits-of-code-only-mapping-and-how-to-get-them, and i was able to generate and import the classes for code mapping. However, i am getting the exception "Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'ID2'."

    It seems, the system is trying to do a select to the DB with that ID2 field, that does not exist.

     

    This is the query that i found in the exception:

    SELECT [Acronym] AS COL1, [AddressID] AS COL2, [AddressID] AS COL3, [BI] AS COL4, [BirthDate] AS COL5, [Board] AS COL6,
    [BossEmail] AS COL7, [Department] AS COL8, [Email] AS COL9, [Name] AS COL10, [Nationality] AS COL11, [Nif] AS COL12,
    [Passport] AS COL13, [Phone] AS COL14, [PlaceOfBirth] AS COL15, [ID2] AS COL16, [QualificationDetail] AS COL17, [QualificationID] AS COL18 FROM [ET_Person] WHERE [ID] = ?     

     

    I don't understand where that ID2 field came from, and i don't know why there isn't an ID field int the select statement.

     

    There is an association between users(Utilizadores) and Person, the association in the code is the following:

    for Person,

    configuration.HasAssociation(x => x.Utilizadors).HasFieldName("utilizadors1").WithOpposite(x => x.Person).HasConstraint((y, x) =>  x.PersonID == y.ID ).IsManaged().IsDependent().WithDataAccessKind(DataAccessKind.ReadWrite);

    and for Utilizadores, 

    configuration.HasAssociation(x => x.Person).HasFieldName("person1").WithOpposite(x => x.Utilizadors).HasConstraint((x, y) =>  x.PersonID == y.ID ).IsManaged().IsRequired().WithDataAccessKind(DataAccessKind.ReadWrite);

     

    I would appreciate any help in this matter.

    If you need any more information, please let me know.

    Thanks!

  2. AndrePereira
    AndrePereira avatar
    6 posts
    Member since:
    Apr 2015

    Posted 09 Aug 2017 Link to this post

    Hi,

    I was able to solve the issue.

    In my case, i had a problem with the foreign keys, of one of the tables that was connected to person.

     

    cheers

Back to Top