title: How can i insert data into database using custom controller method or any other way in ASP.net MVC?
body: <p>I am trying to scrap data from some web page and insert it into database. I got only one table in database called Product that contains ProductID,ProductName,ProductPrice like u can see from model generated using ADO.net Entity Data Model </p>
  
  <pre><code>public partial class Product
      {
          public int ProductID { get; set; }
          public string ProductName { get; set; }
          public string ProductPrice { get; set; }
      }
  </code></pre>
  
  <p>I am new to asp.net mvc(started learning it 3 days ago)so it confuses me a bit ,and cant figure it out where to make new method for scrapping data and putting it into database.
  I was trying to make new ActionResult ScrapData() method in ProductController but when it comes to db.SaveChanges() i get ValidationError</p>
  
  <pre><code>public ActionResult ScrapData()
  {
  
      List&lt;Product&gt; product = new List&lt;Product&gt;();
      HtmlDocument doc = new HtmlWeb().Load("http://www.idea.rs/Proizvodi");
      foreach (var node in doc.DocumentNode.SelectNodes("//div[@class='g2 bp_l_1of4 bp_m_1of3 bp_s_1of2 bp_xs_1of1 item  ']"))
      {
          Product p = new Product();
          p.ProductName = node.SelectSingleNode(".//span[@class='item_title']").InnerText;
          p.ProductPrice = node.SelectSingleNode(".//span[@class='price']").InnerText;
  
          product.Add(p);
  
      }
  
          for (int i = 0; i &lt; product.Count; i++)
      {
          db.Products.Add(product[i]);
          db.SaveChanges();
  
      }
  
      return View(db.Products.ToList());
  
  }
  </code></pre>
  
  <p>Any help is appreciated.</p>