[英]Entity framework re-create related entities
You should read this article, Why Does Entity Framework Reinsert Existing Objects into My Database? 您应该阅读这篇文章, 为什么实体框架将现有对象重新插入到我的数据库中? , by Julie Lerman.
,朱莉·勒曼(Julie Lerman)撰写。 She explains very well why this can occur and how you can avoid it.
她很好地解释了为什么会发生这种情况以及如何避免这种情况。
If there is a relation in database between entities (tables), then upon saving parent object, all the child objects will also be saved if they are not null. 如果数据库中实体(表)之间存在关系,则在保存父对象时,如果所有子对象都不为null,则还将保存所有子对象。
You are probably saving parent entity and then also saving child entities again. 您可能正在保存父实体,然后又保存了子实体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.