If you don't want to use an SQL statement, you can use the Attach method in order to update an entity without having to load it first :using (myDbEntities db = new myDbEntities()){ try { //disable detection of changes to improve performance db.Configuration.AutoDetectChangesEnabled = false; //for all the entities to update... MyObjectEntity entityToUpdate = new MyObjectEntity() {Id=123, Quantity=100}; db.MyObjectEntity.Attach(entityToUpdate); //then perform the update db.SaveChanges(); } finally { //re-enable detection of changes db.Configuration.AutoDetectChangesEnabled = true; }} 这篇关于如何在Entity Framework中批量更新记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-29 22:30