Our is a healthcare application follows (AngularjS+MVC+WebAPI) 3tier architecture. Im uploading an Excel sheet n doing column mappings in an import screen. After that im doing all validations for each n every record in the excel sheet. Afterwards all these 50K rows as entities to Web-API layer. Here im inserting one rec into the parent table to get the primary key. After getting it im looping through the 50k entities to update it in the collection. Then im using addRange to update all these values into the database. Here is a piece of code we have used in the application.
db.tableA.Add(Entity1);
db.SaveChanges();
(Primary Key) fileId = int.Parse(Entity1.Id.ToString());
//DataList having 50K Entities
foreach (tableB coll in DataList)
{
coll.fileID = fileId;
}
db.tableB.AddRange(DataList);
db.SaveChanges();
Referred below links. Bulk insert in entity framework
How to use Bulk Insert in Entity Framework using Object Context?
Bulk insert in entity framework
But i couldnt use the EntityFramework.BulkInsert since its not compatible with the latest EF version(6.1). Is there any other viable approach to use bulk insert using EF? Also can we use SqlBulkCopy in the Entity Framework?`