Я не могу обновить внешний ключ в своей первой базе данных кода Entity Framework 4.3 до нуля.
Моя модель взгляда:
public class AccountViewModel
{
public int Id { get; set; }
public int? CorporationId { get; set; }
public CorporationModel Corporation { get; set; }
}
var corporation = db.Corporation.Where(x => x.Id == model.CorporationId).FirstOrDefault(); // shows as null
account.Corporation = corporation; // sets the value to null
db.Entry(account).State = EntityState.Modified;
db.SaveChanges(); // does not save the null value in the FK field!!!
Любая помощь будет БОЛЬШОЙ признательна.