bbrinck
bbrinck

Reputation: 1103

.NET EF Core Plus BulkInsert takes forever

I have a WebApi where I try to insert, with AppDbContext.BulkInsertAsync(...) from EF Core Plus (https://www.nuget.org/packages/Z.EntityFramework.Plus.EFCore/), 15.000+ records in my database.

Unfortunately it just takes forever, also when I try do insert only 10 records, it takes 15-20 seconds to do so:

AppDbContext.BulkInsert(myEntities.Take(10));

But I need to achieve the following:

// Store the actual Trucks
List<MyEntity> myEntities = new List<MyEntity>(); // <-- Contains more than 15.000 objects
AppDbContext.BulkInsert(newTruckCosts); // <-- This takes forever...

MyEntity has 19 properties, with 5 Foreign Keys to other entities.

I really tried a lot, but I am really stuck here, especially for 15.000+ records it just takes forever.

Could it also be that it takes so long, because my entity has a few Foreign Keys, referencing other entities in my DB ?

Also, don't know if this matters, I am using a SQL Database in Azure (Basic Tier), .NET Core and EntityFramework Core.

Upvotes: 1

Views: 373

Answers (1)

bbrinck
bbrinck

Reputation: 1103

So a major improvement was achieved by upgrading the Azure SQL Database from a Basic Tier to a Standard S1 Tier.

With Basic Tier it just took forever and now with a Standard S1 Tier it takes more or less 15 seconds, which is totally fine in my case.

Upvotes: 1

Related Questions