Here is a post for generating DAL (Data Access layer) using CodeSmith and .Nettiers for any C# project.
For whom don't know what is Codesmith : CodeSmith is a software development tool to help you get your job done faster. Technically speaking it is a template driven source code generator that automates the creation of common application source code for any language (C#, Java, VB, PHP, ASP.NET, SQL, etc.).(http://www.codesmithtools.com/)
And .Nettiers : .netTiers utilizes the power of the best code generation tool available today, CodeSmith. .netTiers generated architecture is custom to your domain, uses familiar patterns, and follows the guidance of Microsoft's recommended patterns and practices. In fact, the .netTiers base architecture is built upon the Microsoft Enterprise Library Application Blocks.(http://nettiers.com/)
To start follow these steps
1-Opening CodeSmith 3.2:
2- From the File menu of CodeSmith press “Open” and select the Nettiers.cst inside NetTiers
3. Open the configuration XML file and change the connection string as in the picture
4. From the Properties Tab click the open icon then select the configuration XML file
5. After Configure the Properties Tab then Press the run icon as below.
6. Be sure that no errors in the generated report and open the solution file (generated in the output directory).
7.Then Build the whole solution from VS
8. After the build succeed open(your output directory\your RootNameSpace.Data.SqlClient\bin\Debug ) and
get the following three DLLs to import them in your own project as the generated DAL (Data Access Layer) .
• your RootNameSpace.Data.dll
• your RootNameSpace.Data.SqlClient.dll
• your RootNameSpace.Entities.dll
Happy Coding :)