So long as the insert into the profile table is occurring first and you are storing the newly inserted id in the session variable called profileid you should be inserting this id with the manage relational table server behavior.
Have you done any testing to ensure that you have this session variable properly set before the MRT server behavior runs? I would like to take a look at your page to see if I can spot an issue and help you debug what is occurring. Please post back with the page in question in a zip archive so that we can take a look.