Change how model name is retrieved.

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