Generate proper model names when dealing with uppercase tablenames.

Pull request for #3449
This is because the relation name generated is:
tABLENAMES
instead of
Tablenames.