title: copy data from one table to another using linq
body: <p>I want to copy data to <code>A_Table</code> data from <code>B_Table</code></p>
  
  <p>So I followed following <a href="http://forums.asp.net/t/1322979.aspx?Copy%20values%20from%20one%20table%20to%20another%20table%20using%20LINQ%20to%20SQL%20" rel="nofollow">ASP.NET  forum post's answer</a> </p>
  
  <p>I just configured that answer according my approach, so this is linq query to copy those data</p>
  
  <pre><code>    public ActionResult Copy_Data()
      {
          var str = from a in db.B_Table select a;
  
          foreach (var val in str)
          {
              A_TableModelClass ls = new A_TableModelClass();
  
              ls.Product_ID = val.Product_ID;
              ls.ProductName = val.ProductName;
              ls.CreatedDate = val.CreatedDate;
  
              db.A_Table.Insert(ls);
          }
  
          db.SubmitChanges();
  
          return RedirectToAction("Action", "Controller");
      }
  </code></pre>
  
  <p>but here I'm getting 2 errors in following location </p>
  
  <p>Error 1</p>
  
  <ol>
  <li><code>db.A_Table.Insert(ls);</code> </li>
  </ol>
  
  <blockquote>
    <p>DbSet' does not contain a definition for 'Insert' and no
    extension method 'Insert' accepting a first argument of type
    'DbSet'</p>
  </blockquote>
  
  <p>Error 2</p>
  
  <ol start="2">
  <li><code>db.SubmitChanges();</code> </li>
  </ol>
  
  <blockquote>
    <p>'ProjectEntities' does not contain a definition for 'SubmitChanges'
    and no extension method 'SubmitChanges' accepting a first argument of
    type 'ProjectEntities'</p>
  </blockquote>
  
  <p>Actually I imported <code>Using System.Linq</code></p>