Solved

LINQTOSQL - Identity Insert is Set to Off???

Posted on 2008-10-26
3
559 Views
Last Modified: 2012-06-27
I have a problem doing an insert via LinqToSql within a table (sql server 2005) that has an identity column (autoincrement).

Error generated is:
Cannot insert explicit value for identity column in table 'sometable' when IDENTITY_INSERT is set to OFF.

Question is, how to do either turn it on in c# code or better yet, keep it on all the time?
0
Comment
Question by:ChiBella
  • 2
3 Comments
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22808252
What you need to do is NOT specify the identity column in your insert and have it auto generate the value.  That is the purpose of identity fields.  
0
 

Author Comment

by:ChiBella
ID: 22808263
I know this...I'm getting error without any specification to the column.

0
 

Accepted Solution

by:
ChiBella earned 0 total points
ID: 22808282
ok, in case anyone else makes the mistake I just did...

If you make a change like adding an identity to a column in sql server, you must remove the table from your dbml and add it back...otherwise you get this error.

0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now