實體框架6中有以下層次模型。在EntityFramework 6中將父實體更改爲子實體6
ChildUser繼承ParentUser。 ParentUser的字段少於ChildUser,我正在使用EF6的Table Per Hierarchy(TPH)繼承結構。
在某些情況下,ParentUser升級到ChildUser,那麼管理這個最好的方法是什麼?
// Naive way that doesn't work and doesn't take into account changing the discriminator
ParentUser parentUser = ctx.ParentUsers.Single(x => x.Id == 1);
ChildUser childUser = (ChildUser)parentUser;
childUser.ExtraField = "Some Value";
ctx.SaveChanges();
任何指向正確方向的指針表示讚賞。
你是什麼意思? – tmg
對不起,我的意思是桌子。我糾正了錯字。 – Adam