Linq To Sql and identity_insert

后端 未结 6 1037
星月不相逢
星月不相逢 2021-01-13 04:29

I am trying to do record inserts on a table where the Primary Key is an Identity field.

I have tried calling
mycontext.ExecuteCommand("S

6条回答
  •  感情败类
    2021-01-13 05:04

    I had the same error message. And I resolve it by changing the properties of the Primary key in the table.

    MyTable.MyId int IDENTITY(1,1) NOT NULL
    

    The property settings MyId (in the dbml)

    • Auto Generated Value: True;
    • Auto-Sync: OnInsert;
    • Primary Key: True;
    • Server Data Type: int NOT NULL IDENTITY;
    • Type: int;

提交回复
热议问题