Refactor entity __ecto__ function generation