Cannot use AUTOINC key generator on a table with multiple primary key columns

Thread is closed for posting
7 posts, 1 answers
  1. richardFlow
    richardFlow avatar
    62 posts
    Member since:
    Jun 2012

    Posted 31 Aug 2010 Link to this post

    I am getting the following error:

    Cannot use AUTOINC key generator on a table with multiple primary key columns 

    It happens when I execute the following line:

     IObjectScope newScope = db.GetObjectScope();

    The table is actually a view, and I've set 3 columns to be the primary key, with none of them set to "Auto Increment".

    I can't find any help on line relating to this error message. Can you please advise?

  2. Answer
    IT-Als avatar
    381 posts
    Member since:
    Sep 2008

    Posted 01 Sep 2010 Link to this post

    Hi Web Belief,

    I has something to do with your mapping - otherwise you wouldn't get it on your call to GetObjectScope (I believe this is the first call made..)

    As far as I can read from your post you have checked the tables for not using "Autoinc" as a type for the keys. Have you also checked the mapping to the class that maps to the view?
    I believe you should set up the Key Generator to "None"


  3. richardFlow
    richardFlow avatar
    62 posts
    Member since:
    Jun 2012

    Posted 01 Sep 2010 Link to this post

    Yes!  Thanks very much Henrik.  

    To clarify for anyone else reading, i had to remove the following line from the app.config file within the class in question.

       <extension key="db-key-generator" value="None" />
    I'm surprised we can't control this from the reverse mapping wizard!

  4. Petko_I
    Petko_I avatar
    184 posts

    Posted 03 Sep 2010 Link to this post

    Hi Web and Henrik,

    We are glad you figured out how to solve the problem. We are constantly trying to automate the tasks when specifying options for a model. Feel free to share your suggestions for improvement with us. We are now concentrating our efforts mainly on the visual designer and slowly the old wizards are moving towards a maintenance mode. That is why you will not see many updates there.

    Do not hesitate to contact us if you have any further questions.

    All the best,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Myth
    Myth avatar
    54 posts
    Member since:
    Jan 2010

    Posted 26 May 2011 Link to this post

    I just had a similar case with the entity designer.

    I had a table that had a combined primary key with the following fields:
    • 1 int, foreign key to another table
    • 1 varchar

    I changed the table so the varchar was also a foreign key to another table.
    What happend was that the entity designer didn't delete the varchar property, and added the new primary key.
    In the designer, i deleted the varchar property manually.
    After this i had the autoinc exception.

    By opening the rlinq file in an xml editor, i changed

              <orm:key-generator name="autoinc" />
                <orm:single-field field-name="_groupId" />
                <orm:single-field field-name="_controlId" />


                <orm:single-field field-name="_groupId" />
                <orm:single-field field-name="_controlId" />

    And it solved the issue.

    Kind regards,
  6. Anders
    Anders avatar
    12 posts
    Member since:
    Apr 2011

    Posted 27 Jun 2011 Link to this post


    Just wanna thanks Myth for his fix to this error.
    Got the same error and opening the rlinq file in an xml editor solved my problem.
  7. Sri
    Sri avatar
    7 posts
    Member since:
    Jan 2011

    Posted 28 Feb 2013 Link to this post

    OMG, thanks for this fix, I had a problem just adding a new row, cause I changed the database to auto-increment and could not insert a row.  I know I had to change the rlinq, I just didn't know how, till I found this thread, thanks so much
Back to Top