Getting Transaction error while trying to save using savechanges() in the inner loop

Viewed 42

I am having an issue when I attempt to call Entity Framework SaveChanges() from within a for each loop. The exception says that "a new transaction while one already exists in another thread". Getting lst from Linq query. So i want to save the data on completion of inner loop. Thanks.

foreach (keyword kwd in lst)
{        
    foreach (DataRow row in dt.Rows)
    {
       //processing
    } 
    //i need saving here.               
    db.SaveChanges();
}
//not here.
1 Answers
Related