MSDN class page

SqlBulkCopy is useful especially to import bulk data ( ~= 600,000, e.g.) records from a SQL or another source to a designated table in a SQL server.

BUT if you do this in a EntityFramework environment in .NET framework, then you might want to have this structure for faster performance.

// set db config properties to false to disable all the auto-detect and auto-validation
dbContext.Configuration.AutoDetectChangesEnabled = false;
dbContext.Configuration.ValidateOnSaveEnabled = false;

// perform bulk copy to SQL
using(SqlBulkCopy myCopy = SqlBulkCopy(sqlConnStr))

myCopy.BatchSize = 100; // row number to send to the server as a batch proc.
myCopy.WriteToServer(your data here);

// Re-set db configuration properties to true.
dbContext.Configuration.AutoDetectChangesEnabled = true;
dbContext.Configuration.ValidateOnSaveEnabled = true;

For details re how to use SqlBulkCopy, pls refer to the MSDN page link at the top of this article. Hope this helps. ­čÖé


What’s the best way to store images, in database vs. in file systems ?

I have found some good answers / suggestions on this question. check this out!

Pros & Cons on storing BLOB data in database

Storing Image in a folder and using URL or relative path in the database

How to save large blob data in sql server

How to save images into database from msdn forum