4.6.0版本 sqlserver2008 强制插入自增列出错! 返回
C#论坛
老数据
4
2837
悬赏:5 飞吻
根据文档说明:
可以设置NULL列不插入和是否强制插入自增列
var t9 = db.Insertable(insertObj2).Where(true/* Is no insert null */, true/*off identity*/)
如果不强制插入自增列,如下代码执行没有问题: DbClient.Insertable<basic_region>(model).ExecuteCommand(); 业务需要我要做强制插入自增列,代码如下: DbClient.Insertable<basic_region>(model).Where(true,true).ExecuteCommand(); 报错内容: 当 IDENTITY_INSERT 设置为 OFF 时,不能为表 'basic_region' 中的标识列插入显式值。 难道这个需要手动开启IDENTITY_INSERT =on 操作么? |
热忱回答(4)
-
fate stay night VIP0
2018/5/22那当然了
0 回复 -
朝歌者-zh VIP0
2018/5/22@fate stay night:手动怎么执行?有示例代码么?
0 回复 -
fate stay night VIP0
2018/5/24执行 关闭 自增的SQL
0 回复 -
fate stay night VIP0
2018/5/24db.ado.execommand(sql)
0 回复