Getting parent's ID is quite easy, as answered here: How can I get Id of inserted entity in Entity framework?
using (var context = new MyContext())
{
context.MyEntities.AddObject(myNewObject);
context.SaveChanges();
int id = myNewObject.Id; // Yes it's here
}
However, I'm asking myself how I can get an ID of new created child entity (one-to-many), where a child has been add to the child collection, like:
existingParent.Children.Add(newChild);
public int Save(Parent parent)
{
context.Update(parent);
context.SaveChanges();
return ???;
}