Before getting into the code-behind, this section will step through the process of using the code generator. It's a trivial process but it is easier to understand the code if you see it in action. The goal is to enable you to create your stored procedures and standard class files without leaving Visual Studio. Let's assume you need to generate the code for the ENTRole table. The first step after the table has been added to the database is to create the stored procedures. The code generator will enable you to use the Add New Item menu to generate the DDL statements to create the standard procedures and then you can execute these against the database. The Add New Item dialog displays the wizard shown in Figure 13-1.
Figure 13.1. Figure 13-1
Notice you can pick from three new templates: V2BusinessClass, V2DataClass, and V2StoredProcedures. If you click on the V2StoredProcedures template and click the Add button, the window shown in Figure 13-2 will appear.
Figure 13.2. Figure 13-2
The Select a Connection list displays the names of the connection strings in any project in the current solution. When you select the connection, the screen will automatically populate the Select a Table drop-down list with all the tables in that database. Click OK to create a new file called ...