I have an entity that has an int as its primary key that is set to storegeneratedpattern = none so that we provide the id client side.
This entity has child entities that reference back to it via an association with navigation and foreign key id.
If I create a new parent entity and add a child, then set the parent entities primary key and save, the fix up of the foreign key for the child happens AFTER the save and is not persisted to the database.
eg
engine = new Engine();
part = new Part();
engine.Parts.Add(part);
engine.Id = 6;
engineRepository.Save(engine);
The save is simply
Context.Engines.AddObject(entity);
Context.SaveChanges();
After the save "part" will have a foreign key "EngineId" = 6, but in the database it will be "EngineId" = 0, ie it appears that the fixup happened after the save.
What am I missing here? It all works fine if the storegeneratedpattern for engine is identity.