This is how to use Codesmith professional version 5.1 without visual studio with Postgresql to generate nhibernate templates.
- First download the Npgsql (version Npgsql2.0.2-bin-ms.net.zip). Extract and copy the "Npgsql.dll" and Mono.Security.dll" files to GAC (c:\windows\assembly). Note: This version of npgsql was determined from the dll not found error emitted when your test connection in Codesmith add data source dialog.
- Now open "CodeSmith Studio".
- In the "Schema Explorer" docking window click "Manage Data Sources". Next click "Add".
- Name your datasource whatever you want. (hence referred to as "yourdatasource")
- Select PostgreSQLSchemaProvider.
- Put in the connection string.
- Your database connection is setup.
- In the "template explorer" click on "create template folder shortcut" icon in the toolbar to create a shortcut to the folder you want to create the Codesmith project in.
- right click the newly created "template folder shortcut" and select "New->Codesmith Project".
- Right click the newly create project and select "Add Output". Browsed and added the following template "C:\Users\Basiee\Documents\CodeSmith\Samples\v5.1\Templates\Frameworks\NHibernate\CSharp". Of course your username / version of codesmith / version of operating system come into play for this address.
- Select your "Source Database" to be "yourdatasource" whatever you called it.
- Modify your "assembly name" (required ... for your ease) as well as the namespaces (optional) to keep them consistent with the assembly name.
- Now right click the project (in Template Explorer) and select "Generate Outputs".
Enjoy!