asp.net mvc linq sql problem

一曲冷凌霜 提交于 2019-12-12 15:17:46

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/2820128/asp-net-mvc-linq-sql-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!