Hi!

I am having problems making entity framework save a detached entity that has child entities.

I have a simple One to One entity that has been mapped like this (the child)

Code:
Me.HasRequired(Function(e) e.MasterObject) _
            .WithRequiredDependent(Function(e) e.AddedData) _
            .WillCascadeOnDelete(False)
This should do it according to various sources I have seen. MasterObject must have one AddedData object and AddedData must have one MasterObject

When saving the object I use the ctx.MasterObjects.Add(myMasterObject) and then ctx.SaveChanges()

The problem is that only the MasterObject is saved, and not the AddedData object. As I understand Add() it will set ALL objects in the graph to EntityState = Added

The SaveChanges() works perfect if I do like this:

Code:
ctx.Entry(myMasterObject).State = EntityState.Added 
ctx.Entry(myMasterObject.AddedData).State = EntityState.Added
ctx.SaveChanges()
But the above code looks too bloated and what should I do for One to Many relationships? SHould I loop all objects and set EntityState = Added? Don't think so

cheers
Henrik