using (var context = new KSKEntities())
{
context.Configuration.AutoDetectChangesEnabled = false;
context.Configuration.ValidateOnSaveEnabled = false;
context.Database.Connection.Open();
using (var ts = new TransactionScope())
{
try
{
context.BulkInsert<KSK.Model.Sample>(SampleList);
context.BulkSaveChanges();
ts.Complete();
Console.WriteLine("bulk insert : OK");
}
catch (Exception ex)
{
ts.Dispose();
Console.WriteLine(ex.ToString());
}
}
}
DB/Entity Framework