MikaelEliasson/EntityFramework.Utilities

Enabling identity insert for InsertAll()

Opened this issue · 0 comments

For some reason I am not able to enable identity insert, do the bulk insert, then disable it again. Am I doing something wrong or is this a bug?

db.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[Orders] ON");
EFBatchOperation.For(db, db.Orders).InsertAll(olist);
db.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[Orders] OFF");

This code ignores the value I've set on the model and uses the next available seeded record in the table.