Fix generated methods to ensure they use Entity references

The `get_entity(name)` method allows to pass an Entity instance reference
as argument of the methods defined through metaprogramming.