Skip to main content
edited tags
Link
marc_s
  • 759.9k
  • 186
  • 1.4k
  • 1.5k
Source Link
redlaz
  • 121
  • 4
  • 10

Entity Framework insertion performance

Im testing using Entity Framework with a Azure Sql db. When inserting 1 record, the action takes 400ms. When adding 20 it is 2500ms.

400ms for inserting 1 record via EF seems like a lot.

What is the normal performance rate for EF?

Am I doing something wrong?

Im aware that bulk insertion can be improved, but I thought that a single insert could be done a lot faster!?

var start = DateTime.Now; testdbEntities testdbEntities = new testdbEntities(); for (int i = 0; i < 20; i++) testdbEntities.Users.Add(new User{Name = "New user"}); testdbEntities.SaveChanges(); var end = DateTime.Now; var timeElapsed = (end - start).TotalMilliseconds;