Add ref support to entities