Is there any maximum size / number of records that can be added to database table with EntityFramework without problems with using a single context.SaveChanges()
after?
Imagine that we have an entity:
public class DbEntity
{
public int DbEntityId {get;set;}
public decimal Value {get; set;}
public string Text {get; set;}
}
And now we would like to add a huge collection of DbEntity
items into database table, like:
var collection = new DbEntity[99999]; // data initialization ommited
context.DbEntities.AddRange(collection);
And then single call:
context.SaveChanges();
Should it be fine, or we should split the data that is about to be added into db and handle it in as a chunks ->
context.DbEntities.AddRange(collection.Take(1000));
context.SaveChanges();
context.DbEntities.AddRange(collection.Skip(1000).Take(1000));
context.SaveChanges();
etc?