?
Solved

LINQTOSQL - Identity Insert is Set to Off???

Posted on 2008-10-26
3
Medium Priority
?
576 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

777 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