Thanks Otis for the reply.
I did that in the first place however I ended up with two new user records, one record properly decorated with all FK values and one "zoombie" with only a PK value.
I thought first it was caused by a cyclic reference between customer - portal - user, however removing this field did not help.
I finally found the cause:
In a multistep enrollment on a single form for a user, in a previous step I checked if the username was free: I created a local new userentity, filled a unique contraint and checked if the user accountname already was in use. This user entity however, was also saved in the final step.
I succeeded now in using the UnitOfWork in a single statement:
work.AddForSave(customer, exp, true, true);
work.Commit;(ds)
Could use a normal ds.SaveEntity probably also.
Learned that a type with a local scope in a method, if attached to a global entity, escapes from the local scope:
user.Accountname = accountName;
user.Customer = CustomerManager.Instance().CurrentCustomer
ds.FetchEntityUsingUniqueConstraint(user, user.ConstructFilterForUCAccountnameCustomerId());
The user.Customer=... statement "pulled" the variable out of the local scope of the method.
So, it was a bug in me, as usually