Solved

LINQTOSQL - Identity Insert is Set to Off???

Posted on 2008-10-26
3
555 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
Comment Utility
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
Comment Utility
I know this...I'm getting error without any specification to the column.

0
 

Accepted Solution

by:
ChiBella earned 0 total points
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL help 5 46
Sql Permission 6 42
How to import SQL 2000 database to SQL 2014 5 78
How to simplify my SQL statement? 9 10
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…
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

12 Experts available now in Live!

Get 1:1 Help Now