update on "index" [solved]
-
Hi all, I was trying to add a row to a table by "InsertOnSubmit" with the first column "id" having "Is Identity = Yes" The problem is that I got an error saying "Cannot insert explicit value for identity column in table 'Polls' when IDENTITY_INSERT is set to OFF." But I only update the two columns follwing the "id" column and why I'm getting this error? Table sqs = ctx.GetTable(); SurveyQuestion sq = new SurveyQuestion(); // "sq.Id" did get update with '0' on the ctr but // I didn't explicitly doing something like "sq.Id = n", that's the problem? sq.Question = "SurveyQue"; sq.Active = true; sqs.InsertOnSubmit(sq); ctx.SubmitChanges(); Update: The question boils down to how could I exlucde certain field from updating when calling "InsertOnSubmit". update: Add "IsDbGenerated = true" to the mapping column will do the trick. Thanks,
modified on Thursday, November 13, 2008 9:17 PM