What do I have to do to have Entity Framework immediately sync the foreign key and the navigation property whenever either is changed, not just after calling SaveChanges
?
public class Model
{
[Key]
public int ModelId { get; set; }
public string Name { get; set; }
public virtual Model Other { get; set; }
[ForeignKey("Other")]
public int OtherId { get; set; }
// Other regular mapped properties not shown
}
I'm using EF 6.1.3 Code First. Change tracking is not explicitly deactivated and should be used.
I need this because my UI grid control changes the ID only (changing navigation object here causes trouble) but my business logic requires information from the referenced object immediately after the ID was changed, before saving the record. The referenced object's data determines what other options the user has to edit the record.