Here Mudassar Ahmed Khan has explained with an example, how to import (insert) CSV file (Text File) data into Database using SqlBulkCopy in ASP.Net MVC Razor.
The uploaded CSV file (Text File) data will be read using File class and the read data will be inserted into SQL Server database using SqlBulkCopy.
SqlBulkCopy class as the name suggests does bulk insert from one source to another and hence all rows from the DataTable can be easily read and inserted using the SqlBulkCopy class.