Cleaned up logic using an if on the format string instead of copied code
Fixed one-to-one relations by adding a <attribute>__entityType column to the table if the destination relation is part of a entity hierarchy
Renamed variable