I use EF 6. I select row from the users
table and use .Include
to also get the address (etc...). Now I want update that address data.
How can I do it?
This code updates only the users
table:
var MyUser = db.Users.Include(b => b.Address)
.Where(x => x.MISPAR_ZIHUY.Equals(123456))
.FirstOrDefault();
db.Users.Attach(MyUser);
db.Entry(MyUser).State = EntityState.Modified;
db.Entry(MyUser).CurrentValues.SetValues(MyNewUser);
db.SaveChanges();