次のコードが機能していないようです。
次のコードを使用したい
db.Entry(user).Property(x => x.Password)
それ以外の
db.Entry(user).Property("Password")
これは、ここにある回答からのコード スニペットですLink。
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();
}
}
私の現在の使用法
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using System.Data.Entity.Infrastructure;