Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • @Beginner: you are though, hence the error. How are we to know that you don't want to insert values? We only have an error message Commented Aug 15, 2011 at 9:47
  • 5
    Error is from my app when i do DB.SaveChanges(); Commented Aug 15, 2011 at 9:50
  • 5
    No, just stop sending a value for the identity column. Or set it if you want in your app if you want to send a value..... but then why have a column with the identity property set to generate values? We can't decide for you Commented Aug 15, 2011 at 10:01
  • 31
    @Beginner: The setting is only applicable in the current session (no one quite pointed that out for this question), so your application would have to turn it on in order for the application to perform such inserts (and it's probably best to promptly turn it off again when such inserts are concluded, like gbn shows). How you were inserting a value on the identity column without realizing it isn't clear, but perhaps older versions of SQL Server would include it implicitly with all columns when explicit insert columns are not specified (?) as Ismael seems to suggest. Commented Jun 3, 2013 at 18:55
  • 2
    @Rob, I think you havea point adn I personally fail code review on any code that does na insert without specifying columns. Aside from the time wasted on an error, this is a risky practice and you can end up with serious data integrity problems if the column data doesn't match up correctly. Commented Nov 5, 2013 at 22:25