Cannot insert explicit value for identity column in table 'table' when IDENTITY_INSERT is set to OFF

前端 未结 22 1177
我在风中等你
我在风中等你 2020-11-22 13:56

I have the below error when I execute the following script. What is the error about, and how it can be resolved?

Insert table(OperationID,OpDescription,Filte         


        
22条回答
  •  感情败类
    2020-11-22 14:41

    Simply If you getting this error on SQL server then run this query-

    SET IDENTITY_INSERT tableName ON
    

    This is working only for a single table of database e.g If the table name is student then query look like this:

    SET IDENTITY_INSERT student ON
    

    If you getting this error on your web application or you using entity framework then first run this query on SQL server and Update your entity model (.edmx file) and build your project and this error will be resolved

提交回复
热议问题