views:

102

answers:

1

Hi all,

I am working on a project using asp.net mvc 2 and linq to sql. The problem occurs when trying to insert data into a table where the table has an identity column type of tinyint. When trying to insert the following error occurs:

The primary key column of type 'TinyInt' cannot be generated by the server.

Does linq to sql support tinyint datatype?

Please help me

+2  A: 

From what I have been able to gather, Linq To Sql doesn't support TinyInt for auto increment fields.

Can you change the datatype to smallint or int?

See the following thread on Microsoft Connect:

When you have a table with an identity field of tinyint and it's set to auto increment, you can't add a new record to that table. LINQ says, 'The primary key column of type 'TinyInt' cannot be generated by the server'

Thank you for taking the time to send this feedback and bug report. We have reviewed the issue and confirmed the behavior, but we will not be fixing this in the next release of LINQ to SQL.

Kelsey
Thanks for your replay,it is a client projects so i dont know whether he is ready to change the datatype.Instead of linq to sql can i use anyother method like entity framework or nhibernate,which one is the best.please help me
Suneesht