DTO -> Entity saveChanges issue

Apr 26, 2013 at 12:26 PM
Edited Apr 26, 2013 at 12:28 PM
Hi ffernandez,

I've created a DTO named SlideDTO. This DTO has a one to many relation with Groups.

After I filled SlideDTO with the needed properties and Groups I convert it to an entity object using
var entitySlide = Context.GetEntitytype<SlideDTO, Slide>(mySlideDTO);
So far everything went ok however after saving I see the SaveChanges action added new groups in the database (this is because the entity state of each group in the Groups EntityCollection is 'Added'). This is happening for all one-to-many associations.

How to prevent this? I don't want to create extra groups in my database.


Jun 28, 2013 at 2:04 AM
Hi Marcel.
Sorry for the too late response, been busy with other projects.
Could you not add the Groups to SlideDTO? I imagine you can't so is there any chance you set the EntityState to every Group of the SlideDTO before calling SaveChanges?
Marked as answer by ffernandez on 12/30/2013 at 6:58 PM