Change the order of save() functions.

1. Save the db model. Make sure this saves ok without errors.
2. Update the datastore itself.
3. Update any datastore connections.

Otherwise we risk trying to update something that hasn't been created
yet.

Change-Id: Ic39ae7bb3c73e48c07810662dc73a442779fb831