这是表
用户数
UserId UserName Password EmailAddress
和代码..
public void ChangePassword(int userId, string password){ //code to update the password.. }
Ladislav的答案已更新为使用DbContext(在EF 4.1中引入):
public void ChangePassword(int userId, string password) { var user = new User() { Id = userId, Password = password }; using (var db = new MyEfContextName()) { db.Users.Attach(user); db.Entry(user).Property(x => x.Password).IsModified = true; db.SaveChanges(); } }