无法在表格中插入标识列的值... [英] cannot insert value for identity colum in table...

查看:113
本文介绍了无法在表格中插入标识列的值...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[AcceptVerbs(HttpVerbs.Post)]
 
public ActionResult CreateUser( [Bind(Exclude="IdUtilisateur")Utilisateur UtilisateurCree)
{
if (!ModelState.IsValid)
 
return View();
 
_db.AddToUtilisateurs(UtilisateurCree);
_db.SaveChanges(); 
return RedirectToAction("CreateUser");
}



创建时会返回异常!!!!!


it returns an exception when creating!!!!!

_db.AddToUtilisateurs(UtilisateurCree);



例外:当IDENTITY_INSERT设置为关闭时,无法为表''用户'中的标识列插入值''


Exception: "cannot insert value for identity colum in table ''users'' when IDENTITY_INSERT in set to off''

推荐答案

您正在一个标记为标识列的数据库表列中显式插入一个值。删除该列的标识或不传递要插入表中的代码的值。
You are explicitly inserting a value in one of your database table column that is marked as an identity column. Either remove identity for that column or do not pass value from code to be inserted in the table.


试试这个...

Try this...
USE DATABASENAME
GO
SET IDENTITY_INSERT [TABLENAME] ON
INSERT [TABLENAME] ([AUTOIDFIELDNAME]) VALUES(1)
SET IDENTITY_INSERT [Tbl_Co_IEUpdateId] OFF
GO


这篇关于无法在表格中插入标识列的值...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆