IDENTITY INSERT and LINQ to SQL

后端 未结 6 1336
难免孤独
难免孤独 2020-12-03 08:04

I have a SQL Server database. This database has a table called Item. Item has a property called \"ID\". ID is the primary key on my table. This primary key is an int with a

6条回答
  •  醉酒成梦
    2020-12-03 08:56

    It sounds simply as though your model is unaware of the fact that it is an identity; the ID column should be marked as db-generated (Auto Generated Value in the UI, or IsDbGenerated in the xml), and probably as the primary key. Then it will not attempt to insert it, and will update the value correctly after it is written.

提交回复
热议问题