Tutorials ADO.NET Core Tutorial
Bulk Insert — Complete Guide
Bulk Insert — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of ADO.NET Core Tutorial on Toolliyo Academy.
On this page
ADO.NET Core Tutorial · Lesson 19 of 100
Bulk Insert
Foundations → SQL & safety → Production → Projects
Foundations · 1 — Connections & CRUD · ~6 min · Module 2: CRUD Operations
What is this?
SqlBulkCopy loads many rows fast from a DataTable, reader, or IDataReader into a table.
Why should you care?
ShopNest catalog imports and warehouse feeds cannot insert row-by-row.
See it live — copy this example
Use a .NET console or API project with SQL Server LocalDB. Run dotnet run after pasting.
using var bulk = new SqlBulkCopy(conn) { DestinationTableName = "StagingProducts" };
bulk.ColumnMappings.Add("Sku", "Sku");
bulk.ColumnMappings.Add("Name", "Name");
await bulk.WriteToServerAsync(table, ct);
Console.WriteLine("bulk done");
What happened?
- Map columns explicitly.
- Use a staging table then MERGE.
- BatchSize helps huge loads.
Practice next
- Create StagingProducts.
- Fill DataTable.
- WriteToServerAsync.
- Set BatchSize = 1000.
- Enable FireTriggers carefully.
Remember
SqlBulkCopy for volume. Stage then MERGE. Map columns.
ShopNest catalog import
Merchant CSV → staging → Products.
Outcome: Minutes instead of hours.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!