Fixes exception when a new entity is created