Need to speed up writing large object graph to database with Entity Framework

asp.net-core-webapi c# ef-core-2.1 entity-framework-core

Accepted Answer

I was able to reduce the 5 minute Insert time to around 30 seconds by using the Extended Entity Framework sample version. It worked wonderfully, but using that approach would have cost money. It worked after I only inserted a using clause and one line of code.

_context.AddRange(history);
//_context.SaveChanges(); <-- Previous Code
_context.BulkSavechanges();  //New Entity Framework Extensions Code

I gave EFCore a go. BulkExtensions. I could not make this work. My Fluent API Entity Map's Conversion mapping didn't appear to sit well with it.

builder.Entity<Transaction>()
  .Property(t => t.Receiver)
  .HasColumnName("receiverdata")
  .HasConversion(v => JsonConvert.SerializeObject(v), v => JsonConvert.DeserializeObject<ReceiverEntity>(v));

EFCore. I'm not sure what the problem is because BulkExtensions indicates that they support Conversion. It will be interesting to see whether there is a method to make this work or not when I put the issue on GitHub.

2
12/20/2018 8:28:28 PM

Popular Answer

ZZZ_tmp


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow