Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Camel case table names in MySQL

, 27 Mar 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
A solution to casing problems in MySQL.

I have been working with Entity Framework 4 and MySQL. The main problem I have found is that since I am working on a windows server, the table names in the database are all lower case. This means that when I create the entities in Visual Studio, the classes are all lower case.

So I have found this solution:

There is a setting in the configuration file in the MySQL server directory. I am using Windows 7, so this was under: C:\Program Files (x86)\MySQL\MySQL Server 5.5C:\Program Files (x86)\MySQL\MySQL In this Server 5.5\.

In this directory, you will find a file: my.cnf. This governs how MySQL runs. You will need to change or add a line to allow Camel casing of table names. Please note that you should read http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html. This details the changes and how they should be used on different Operating Systems. I am only detailing how I got this to work on Windows. If you are running Linux, then please go to the link mentioned above to make sure that the change will not affect your system / MySQL instance.

Steps taken to allow Camel casing:

  • Go to Control Panel –> Administrative Tools –> Services.
  • Stop the MySQL Service.
  • Open C:\Program Files (x86)\MySQL\MySQL Server 5.5C:\Program Files (x86)\MySQL\MySQL In this Server 5.5\.
  • Open the my.cnf file as Administrator.
  • Add the line lower_case_table_names=2 under the mysqld section. If this line is there, then just change the value to ‘2’. Make sure that there is only one line there.
  • Go back to Services and restart MySQL.

You should be done. Hope this short guide has helped.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

stephen.vaubell
Software Developer (Senior)
United Kingdom United Kingdom
No Biography provided

Comments and Discussions

 
GeneralThanks! PinmemberMertiin13-Jul-14 21:17 
GeneralVery good post to learn MySQL PinmemberKelly Blue17-Jun-11 20:54 
Oh this is a great tutorial!!! It’s help me a lot.
Of course i find some very userful MySQL examples with ready made code examples and output screenshot.
 
Kelly Blue
University of Technology, Sydney, Australia

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141030.1 | Last Updated 27 Mar 2011
Article Copyright 2011 by stephen.vaubell
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid