https://stackoverflow.com/a/31856991/5852947
The above answer details how to insert identity column using EF6. You need:
- using (var transaction = dataContext.Database.BeginTransaction())
- dataContext.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[User] ON");
- transaction.Commit();
- change StoreGeneratedPattern property of identity column from Identity to None in model designer
This solution worked for me.
But in the same program once I need to insert a row with identity, and once without identity. It seems it is not possible because you have to set the value of StoreGeneratedPattern before compiling the program.