using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace EFDemo { class Program { static void Main(string[] args) { //创建数据库上下文对象 EFDBEntities efdb = new EFDBEntities(); //想修改对象,首先找到要修改的对象 // Students objStudent = efdb.Students.FirstOrDefault(s => s.StudentId ==100006); Students objStudent = (from s in efdb.Students where s.StudentId == 100006 select s).First<Students>(); //再次修改各个属性值 objStudent.StudentName = "张红利"; objStudent.PhoneNumber = "88888888"; //提交保存 int result = efdb.SaveChanges(); Console.WriteLine(result); Console.ReadLine(); } } }