---
title: "Update problems in Entity Framework"  
description: "Update problems in Entity Framework"  
author: "Anonymous User"  
published: 2013-09-28  
updated: 2013-09-28  
canonical: https://www.mindstick.com/forum/1544/update-problems-in-entity-framework  
category: "ado.net"  
tags: ["ado.net"]  
reading_time: 1 minute  

---

# Update problems in Entity Framework

I want [update](https://www.mindstick.com/forum/156353/what-is-hummingbird-update) my [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap) with two [conditions](https://www.mindstick.com/blog/394/javascript-if-else) :

Type == "[Employee](https://www.mindstick.com/articles/85431/remote-employee-training-tips-tricks)" &[amp](https://www.mindstick.com/forum/156207/what-is-amp);& Approved == false

and I use this [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) :

```
using (NoavaranModel.NoavaranEntities1 db=new NoavaranModel.NoavaranEntities1())
{
    var query = db.Students.Where(p => p.Type == " Employee" && p.Approved == false).Single();
    query.IsRecivedSMS = true;
    db.SaveChanges();
}
```

but it's not working. Just [updates](https://yourviews.mindstick.com/view/85235/global-efforts-to-combat-climate-change-updates-and-initiatives) one recode in db. How can I update all rows with above conditions in [Entity Framework](https://www.mindstick.com/articles/1566/crud-operations-using-entity-framework-code-first-approach)?

## Replies

### Reply by Anonymous User

Hey Goti!

Just change the query to not select only one record which fits your contition, but all. Then update them all.

```
using (NoavaranModel.NoavaranEntities1 db=new NoavaranModel.NoavaranEntities1())
        {
            var query = db.Students.Where(p => p.Type == "پیش ثبت نام" && p.Approved == false);
            foreach(var record in query)
            {
              record.IsRecivedSMS = true;
            }
            db.SaveChanges();
        }
```


---

Original Source: https://www.mindstick.com/forum/1544/update-problems-in-entity-framework

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
