gpt4 book ai didi

c# - Visual Studio 2012 不创建新的 SQL 表

转载 作者:行者123 更新时间:2023-11-28 23:57:27 25 4
gpt4 key购买 nike

我想在 Visual Studio 2012 中创建一个简单的 SQL 表,id 字段是自动递增主键,所以我这样做:

enter image description here

但是当我想更新 和创建表时出现错误:

** 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.

最佳答案

从 Id 列定义中删除默认值。

如果它是标识列,则初始条目将设置为“标识种子”值,后续记录将根据“标识增量”值进行更新。

关于c# - Visual Studio 2012 不创建新的 SQL 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31244445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com