if it is a relationship, you should create it before you make the connection to the entity.
If it is just a number, you can always get the last one and add one (because it is auto-incremented). But I do think the correct thing to do is to create it before assigning it.