using (var ctx = new PortalContext())
{
var city = ctx.Cities.Find(42);
ctx.Entry(city)
.Reference(c => c.Province)
.Load();
city.Province = null;
ctx.SaveChanges();
}
Entity Framework 更新带外键的实体为null
原文:http://www.cnblogs.com/lishidefengchen/p/5338136.html