Change how model name is retrieved.

Following Simon Bennet suggestion, I changed how the table name
is retrieved from the model, to make the generators compatible with
namespaced models.