How to fix the .Net error: Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF
When attempting to save changes to a table the following exception is thrown.
Cannot insert explicit value for identity column in table when
IDENTITY_INSERT is set to OFF
Unfortunately, I had to drop the table and then add it again with the following
constraints. I suspect what I was missing was the FILLFACTOR property which has
to do with page splits. Perhaps if you can add this property to an existing
table you will not need to drop and add.
CONSTRAINT [PK_tbMyTableName] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON,
FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
See also