Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7860351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:15:15+00:00 2026-06-02T22:15:15+00:00

the primary key column of type ‘tinyint’ cannot be generated by the server… This

  • 0

the primary key column of type ‘tinyint’ cannot be generated by the server…

This is more of an answer than a question because I’ve been searching for this on stack and couldn’t find any question/answer to help.

Basically, I was trying to do an insert (below)

public void AddTask(Task task)
{
    TwoDooDataContext db = new TwoDooDataContext();
    db.Tasks.InsertOnSubmit(task);
    db.SubmitChanges();
}

And my primary key was set Identity true but the data type was set to TinyInt…see class attributes below

ColumnAttribute(Storage="_ID", AutoSync=AutoSync.OnInsert, 
DbType="TinyInt NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]

Doing this caused the error message:

the primary key column of type ‘tinyint’ cannot be generated by the
server

So I couldn’t figure this out until I could this link…
http://connect.microsoft.com/VisualStudio/feedback/details/402060/accessing-a-primary-key-id-when-its-declared-as-a-tinyint-using-linq

It’s a known issue but not fixed – I’m using SQL 2008 Express and VS Web Developer 2010 Express.

My fix was just to change the data type to Int and everything works. Hope this helps incase anyone else is looking for solution.

And actually a question – What’s the best data type to use in my case? Should I keep it as Int or change it even though it’s working?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:15:17+00:00Added an answer on June 2, 2026 at 10:15 pm

    Database Administrators has a nice discussion of when to use TINYINT over INT although I don’t think it applies in your case. If using an int gets you past the known issue, you’d need a very good reason to change it. I’d leave it as is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to change the type of my primary key column on a table
I am trying to alter column datatype of a primary key to tinyint from
I have found that how to determine what columns are primary key column of
When inserting a row into a table with an auto increment primary key column,
Few basic doubts I have: 1. Is primary key column automatically indexed? 2. What
I have a two-column primary key on a table. I have attempted to alter
I have a table whose primary key is a column named St_ID . I
The first column in a MySQL table of mine is the primary key with
If I set a database column as an autonumber primary key field, will the
So I have a table with an identity column as the primary key, so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.