- Published on
- Authors
- koskila
How to resolve "Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF"
Okay, okay - another super simple thing that I messed up, fixed, and decided to document :) This time I messed up a simple operation in Entity Framework Core operation on a simple entity, and hopefully I'll save someone else some trouble! Onwards to the issue, then! Problem So when you're trying to insert stuff into your database - somewhat like shown in the example below: var entity = new MyEntity(){ Id = 1337, Name = "My Entity" }; _ctx.MyEntities.Add(entity); _ctx.


