Generate proper model names when dealing with uppercase tablenames.

Pull request for #3449
What's this change for? It doesn't seem to be related.