A step by step description on how to
generate code using OxyGen Code Generator follows
Open OxyGen Code Management Studio.
In the Connect to Server dialog specify
the Server Name,
the Authentication mode, user credentials (if SQL Server Authentication is
selected), and then click the Connect
button.
The Database
Explorer tree control is populated with the databases for the
specified server. Accessible databases are depicted by an enabled cylinder () while the databases that are not accessible are depicted by a
disabled cylinder ().
Note
In Windows Vista, some of the databases
may be not accessible if Windows Authentication is selected and the
application does not run under an administrator role.
Click Processing\Source Code GeneratorWizard…
menu item (or the Source Code Generator toolbar item). The Code
Generator Settings wizard is displayed in “Figure 34: Code Generator Settings wizard. Database connectivity step”.
In the Database Connectivity step,
specify the Server
Name,Authentication,
Database Name,
Connection
Timeout (measured in seconds), User Name (SQL
account user name to connect to the database), and Password.
To test your connection settings, click the
Check Connection
button. If the check fails review your Server Name information. The Server
name of a SQL Server database instance is not always the machine name.
Click the Next button. The Database Objects
step is displayed.
In the Database Objects step
specify the tables, views and stored procedures primarily used to generate
the source code.
Click the Next button. The Component Packages
step is displayed.
Specify the desired component package to
be generated by selecting the appropriate radio button from the Component Packages
radio buttons group. OxyGen Code Generator generates 4 kinds of
application model components.
Stored Procedures
Data Access Layer
Business Layer
Hosted applications:
ASP.NET Web UI
Web Services
Windows Communication Foundation
Services
“Appendix B – Source Code Component Packages” describes
the source code component packages.
Click the Next button. The Solution and Project Settings step
is displayed.
Specify the Visual Studio solution and
project formats, the solution name and the project names for the generated
source code. For Visual Studio 2008 file format we can specify the target
framework (2.0, 3.0 or 3.5)
Click the Next button. The Data
Activities step is displayed.
Specify the desired stored procedures
categories to be generated. The Retrieve Stored Procedures is preselected and
compulsory.
Click the Next button. The Paging
and Caching Settings step is displayed.
Specify the generated code paging and
caching options.
Click the Next button. The Stored Procedures Configuration
step is displayed.
Specify the SQL logins from which the Stored
Procedures’ execute right is granted.
Click the Next button. If any of the C#
output components (Data Access Layer or Business Layer) are selected in
the Components section, the Generated
Code Settings step is displayed; otherwise the Source Code Publishing Settings
step is displayed. In the Generated Code Settings step,
you specify the namespaces for your C# components (Data Access and
Business Layers)
Click the Next button. The Data
Access Layer Settings step is displayed.
Specify the data access layer settings
for the generated source code and create additional Interfaces, Class
Attributes, Method Attributes and Member Attributes. Click the Next button
and the Business Layer Settings step is displayed.
Specify the business layer root
namespace, the assembly name, the intercepts settings and optionally the
base class name, interfaces and attributes for generated source code.
Click the Next button and the Service Layer Settings step is
displayed.
Specify the services root namespace,
intercepts options and the service interface class name for the generated
source code. Click the Next button and the Web Service Settings step
is displayed.
Specify the Web Services attributes and
the intercepts option for the generated source code. Click the Next button
and the WCF Services Settings step is displayed.
Specify the WCF Services attributes, the
intercepts options and binding and behavior options for the generated
source code. Click the Next button and the Source Code
Publishing Settings step is displayed.
Select the publishing settings for the
generated source code. Specify the publishing root folder or specify the
folder for every single component separately.
Click the Next button. The Code Generation Actions step
is displayed.
In the Code Generation Actions step, we
can optionally, specify the following:
The Pre-generation and Post-generation
command lines. These are cmd.exe statements that can be executed prior to
or after code generation.
Run Stored Procedures SQL scripts. After
code generation, this option will cause scripts to run that will create
the Stored Procedures in the database.
Compile Data Entities. After code
generation, this option will cause the compilation of the DAL using
csc.exe
Compile Business Entities. After code
generation, this option will cause the compilation of the BL using
csc.exe
Open generated code with Code Explorer.
Open generated code with Visual Studio.
Start Web UI. After code generation,
this option starts up the Web Server that comes with the .NET Framework (WebDev.WebServer.EXE)
and then browses to the default page of the generated ASP.NET UI.
Click the Next button. The Code Generator Review step
is displayed.
Figure 35: Code generation review step screen
Click the Finish button to invoke the code
generator or the Cancel
button to cancel the process and close the dialog.
The processing instructions can optionally be validated before starting
code generation. It is recommended that the processing instruction be
validated if the code is generated for the first time against any
particular database. When code generation is started, a progress dialog is
displayed informing the user about the code generation step that is
currently being performed. You can abort the code generation process by
clicking the Cancel
button. The following screen shotshows the Code Generator Progress
dialog box.
Figure 36: Code Generator Progress dialog
On a successful code generation session,
the source code explorer dialog is displayed. This allows the user to view
the files (T-SQL, C# and ASP.NET) that have been generated.