Error with TinyInt Identity RRS feed

  • Question

  • I get error when calling SubmitChanges().
    The error is.
    The primary key column of type 'TinyInt' cannot be generated by the server.

    I created table like this:
                Column column;
                column = new Column(table, "ID");
                column.DataType = DataType.TinyInt;
                column.Nullable = false;
                column.Identity = true;
                column.IdentityIncrement = 1;
                column.IdentitySeed = 1;
    Sunday, October 18, 2009 8:26 AM


  • It appears that LINQ to SQL does not like byte properties being used for identity. An easy work-around is to change your ID column in the LINQ to SQL designer from byte to int.

    Given that the field is read-only from the server anyway and int is larger than byte this should work fine.

    • Marked as answer by Yichun_Feng Friday, October 23, 2009 1:39 AM
    Sunday, October 18, 2009 6:02 PM