IDENTITY INSERT and LINQ to SQL

后端 未结 6 1338
难免孤独
难免孤独 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:54

    You must define in your mapping that id is generated in the database. The way to do this depends on the type of mapping you are using. if you are using code attributes make sure that you specify IsDbGenerated in the ColumnAttribute for the Id property (or in XML mapping). if you are using dbml file make sure that Auto Generated Value is set to true.

提交回复
热议问题