1

I want to insert a single record into a table with 60 columns (some of them are not required) and 2 million records. It takes about 20 seconds.

var package = new Package()
      {
          DestinationCityId = city.Id,
          OriginCityId = RequestDetails.User.Retailer.CityId,
          State = state,
          CreatedOn = RequestDetails.DateTime,
          CreatedByUserId = RequestDetails.User.Id,
          OrderedOn = RequestDetails.DateTime,
          CustomerName = "a",
          CustomerAddress = "a",
          CustomerEmail = "a",
          CustomerPostalCode = "a",
          CustomerLandPhone = "a",
          CustomerCellPhone = "aa",
          CustomerMessage = "a",
          CustomerSubstitute = "a",
          RetailerPackageDiscount = 0,
          Barcode = "2",
          InternalBarcode = "11111",
          PackagingWeight = 10,
          DeliveryType = PackageDeliveryType.ByPostExpress,
          ProvidedByWarehouse = false,
          NeedReview = false,
          NeedReviewType = NeedReviewType.Unknown,
          RetailerId = retailer.Id,
          Retailer = retailer
      };

DbContext.ZPackages.Add(package);
DbContext.SaveChanges();

Any Idea to improve performance?

2 Answers 2

2

Partitions, Indexes, Async CRUD operations where it possible. This is not EF problem

Sign up to request clarification or add additional context in comments.

Comments

-1

You could also have a look at the EfCore Bulk Extensions project if you're using EF Core https://github.com/borisdj/EFCore.BulkExtensions

1 Comment

This isn't going to help: the OP is just inserting one record.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.