One of the best code generators out there is MyGeneration. It is open source and free (as in zero cost). You can get the latest version from http://www.mygenerationsoftware.com or from the SourceForge project page at http://sourceforge.net/projects/mygeneration.
According to their SourceForge page:
MyGeneration is an extremely flexible template-based code generator written in Microsoft.NET. MyGeneration is great at generating code for ORM architectures. The metadata from your database is made available to the templates through the MyMeta API.
The MyGeneration templates are typically database-driven, so your model is stored in the database and the rest of the data layer is generated.
MyGeneration has a very clean, simple interface, and is very user-friendly. As an added bonus, if you don't like the way a feature works, remember, it's open source, so you can download the source code and change it!
Much like CodeSmith, MyGeneration uses templates to render the code it generates. Therefore...