Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
—> Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot insert explicit value for identity column in table ‘Books’ when IDENTITY_INSERT is set to OFF.
at Microsoft.Data.SqlClient.SqlCommand.<>c.b__211_0(Task1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask
2.InnerInvoke()
Can’t insert the values in the Database Table through the code.
But when I’m using SSMS directly Insert operation works, and for that I’ve to use
SET IDENTITY INSERT {TABLE_NAME} ON.
Unable to use POST Request in API.
I want a solution so that it won’t ask for Identity Insert to turn on again and again.
Kunal Sisodia is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.