SoheilYou
SoheilYou

Reputation: 949

Visual Studio 2012 does not create new SQL table

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 :

enter image description here

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

enter image description here

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

Answers (1)

mfdoran
mfdoran

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

Related Questions