Codesmith Tutorial (1) Overview

Source: Internet
Author: User
Tags command line mysql database visual studio

We are introducing the Hibernate development tutorial, which mentions that hibernate on the. Net platform is nhibernate, using nhibernate cannot help mentioning Codesmith.

Codesmith is a template-based code generation tool that uses a syntax similar to asp.net to generate any type of code or text. Unlike many other code generation tools, Codesmith does not ask you to subscribe to a particular application design or architecture. With Codesmith, you can generate anything that includes simple, strongly typed collections and complete applications. When you build your application, you often need to do some specific tasks repeatedly, such as writing data access code or building a custom collection. Codesmith is especially useful at these times, because you can write templates to automate these tasks, not only to increase your productivity, but to automate the most tedious tasks. Codesmith comes with a number of templates, including templates for all. NET collection types and templates for building stored procedures, but the real power of the tool is the ability to create custom templates.

Codesmith can be downloaded from the website http://www.codesmithtools.com/, personal development version of the cost of 300 dollars or so, personally think that the value of money.

Or with an example to illustrate the use of codesmith can greatly reduce the workload of the program code, for database applications, although the database table is not the same, but the basic process is to define the database table, design the corresponding class, and then use ADO or SQL statements to access the database, Create the corresponding class object, and so on.

Using the templates provided by Codesmith, you can automatically generate these database-related code without a single line of code written by hand.

This example uses Visual Studio to provide Visual Studio plug-in support during Codesmith installation. The sample database used is also sales, see Hibernate development Tutorial (2): Ready to start.

The MySQL. Net library needs to be downloaded as a result of using the MySQL database. Use SQL Server to use directly.

1. Create a command line to apply solution.

2. Use Codesmith schema Explorer to add a MySQL data source

The connection String here is: server=localhost;database=sales; Uid=username; Password=password; (depending on your own server to modify the parameters)

After the addition is successful, the table definitions of the connected databases are displayed in schema Explorer, and so on

3. Add a sales.data Class Library to this solution. Then add a Codesmith project item to the project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.