I use BindingSource with Entity Framework and when I call
EntityContext.SaveChange();
it takes more time to execute, then the next time I add new objects to the binding source and then call SaveChanges (); Method
EDIT 2
More details:
When a upload form event
BindingSource.DataSource = EntityContext.Table;
Add New Button
BindingSource.AddNew();
Table m_object= (Table)BindingSource.Current;
m_object.ID = Guid.NewGuid();
Other object data is edited using controls bound to its properties.
And then the save button
BindingSource.EndEdit();
Stopwatch sw = new Stopwatch();
sw.Start();
EntityContext.SaveChanges();
sw.Stop();
Console.WriteLine(sw.Elapsed.ToString());
If I repeat adding and saving several times, I get the following output:
00: 00: 01.0788243
00: 00: 00.0316786
00: 00: 00.0292763
00: 00: 00.0298630
00: 00: 00,1127312
It is noteworthy that the first operation of adding and saving takes almost one second, and then the next time I add and save.