title: Populate database with IEnumerable objects from CSV file
body: <p>I have a CSV file containing all Products from which I have a method in a new class converting them into C# Product objects which get stored in a variable of type IEnumerable:</p>
  
  <pre><code>public class ReadCSVFile
  {
      public List&lt;Product&gt; ProductsList;
  
      public ReadCSVFile()
      {
  
          var path = @"/Content/TrendyDinersLimited_Self_ProductUpdateTemplate.csv";
  
          var CSVProducts = from line in File.ReadAllLines(path).Skip(1)
                            let columns = line.Split(',')
                            select new Product
                            {
                                Id = int.Parse(columns[0]),
                                Name = columns[1],
                                Price = int.Parse(columns[4])
                            };
      }
  }
  </code></pre>
  
  <p>My question is, now that I have a list of Products from the CSV file, how should I populate them into my database (as a one time import)? Usually, the admin would create a category first, then click on a category to add products. </p>
  
  <p>I am using an ASP.NET MVC template in Visual Studio and I have three main controllers: HomeController(displays categories and products), CategoryController(Admin Authorised), ProductController(Admin Authorised). I am also using a direct connection string to a Microsoft SQL Server. </p>