Reputation: 949
I want to create a simple SQL table in Visual Studio 2012 that th id
field is Auto increment primary key, so I do like this :
But when I want to Update and create table it errors :
** Highlights
Tables that will be rebuilt
None
Clustered indexes that will be dropped
None
Clustered indexes that will be created
None
Possible data issues
None
** User actions
Create
[dbo].[sotbl] (Table)
Default Constraint on [dbo].[sotbl].[Id] (Default Constraint)
** Supporting actions
Creating [dbo].[sotbl]... Creating Default Constraint on [dbo].[sotbl].... (86,1): SQL72014: .Net SqlClient Data Provider: Msg 1754, Level 16, State 0, Line 1 Defaults cannot be created on columns with an IDENTITY attribute. Table 'sotbl', column 'Id'. (86,1): SQL72014: .Net SqlClient Data Provider: Msg 1750, Level 16, State 0, Line 1 Could not create constraint. See previous errors. An error occurred while the batch was being executed.
Upvotes: 1
Views: 486
Reputation: 335
Remove the default value from the Id column definition.
If it is an identity column the initial entry will be set to the 'Identity Seed' value and subsequent records will be updated based on the 'Identity Increment' value.
Upvotes: 1