实体框架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