Has EF6+ / 7 added any ways that I can add update child tables?

元气小坏坏 提交于 2019-12-06 20:29:29

has noted on the ef7 github they seams to have added some neat code that add primary key entity.

but it is still not clear as to if it will be a common thing for children collection in an entity. Git hub Entity Framework Design Meeting Notes

but for EF6 you could use a Generic Repository to make all the work for you. (since you can't extend DbContext directly)

assuming db is a DbContext

you could use this -> : Accessing a Collection Through Reflection

then find all Property from a class T that contains ICollection<> and do a foreach on the item of the ICollection Property then do db.Set.Add(proprietyChild) on it

that would eliminate the need for always repeating the same add child to entity code.

some people already did implement a solution thou : Automated updates of a graph of deached entities

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!