asp.net mvc linq sql problem
Asked Answered
L

1

3

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

Ludwick answered 12/5, 2010 at 15:12 Comment(0)
M
3

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.

Mingle answered 12/5, 2010 at 15:18 Comment(1)
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 meLudwick

© 2022 - 2024 — McMap. All rights reserved.