This C# library will support Csv to Database table creation using Mssql and Npgsql programmatically with minimal line of codes.


Csv to Database
  • .NET Core 3.1
  • VSCode
  • Go to Tools and select Manage Nuget Packages and Search for CsvToDb library.
    Install-Package CsvToDb -Version 1.0.2
private readonly string _connString;

public UploadController(IConfiguration config)
_connString = config["CONNECTIONSTRING_MSQL"];

[RequestFormLimits(ValueLengthLimit = int.MaxValue, MultipartBodyLengthLimit = int.MaxValue)]
public async Task<IActionResult> TestCsvToDb(IFormFile file)
//From IFormFile
await CsvToDbService.ExecuteAsync(file, new ToDbOptions()
TableName = "Customer",
Delimiter = ",",
UsedMssqlDb = true,
UsedSnakeCase = true,
DbConnectionString = _connString,
//From file path
await CsvToDbService.ExecuteAsync(@"{csv-file-path}", new ToDbOptions()
TableName = "Customer",
Delimiter = "|",
UsedMssqlDb = false,
UsedSnakeCase = true,
DbConnectionString = _connString,

return Ok("Success!");

note: It will upload 1 million rows and 15 columns within a minute.

  1. Go to your database Npgsql or Mssql and check if the records are successfully created on the said table name.

note: I did not implement any logs for this library especially on connection string for security purposes.
You can use local database to persist temporarily the records from uploaded csv.


Copyright © 2020 Joever Monceda

Linkedin: Joever Monceda
Medium: Joever Monceda
Twitter @_EthanHunt07
Facebook: Ethan Hunt

Looking for a JOB? Signup @ jobbhy and be notified!

Want to post a JOB as employer? Contact and be one us!

Read more about jobbhy:
Jobbhy — Smart Hiring | Job Vacancies | Recruitment




JSanitizer (Configurable sanitizer for XML and JSON.)

Sr. Software Integration Developer @ Interprit