Generating source code and installation scripts
Another important feature of Visual Studio. NET is its ability to generate a complete build script for an existing database. In fact, you can use Visual Studio. NET to generate source code for the entire database tier, including making tables and indexes, authorizations, stored procedures, and so on, and to generate a command-line script that can be used to install these database objects on an existing SQL Server.
Building the installation script is easy, it includes two steps: First, you need to generate T-SQL scripts to create database objects (tables, indexes, procedures, and so on). Then, a command-line script is generated that executes the T-SQL script for the target SQL Server.
Generating T-SQL scripts
Before generating the installation script, you need to generate a collection of scripts, including creating all objects in the database (tables, indexes, constraints, users, and so on).
Figure 11: Generating a Script collection
Here are the steps to generate a T-SQL script:
In Server Explorer, right-click on the selected database node (DotNetKB), and then select Generate Create Script from the context-related menu ... (Generate Create Script ...) , open the Generate create Scripts (Generate Creation Script) dialog box.
On the General tab, select the Script all objects (write all object script) check box.
On the Formatting tab, select all the check boxes except the Last check box (features that are compatible with version 7.0 scripts only). The last item is required only if your target server is SQL Server 7.0 instead of SQL Server 2000.
On the Options tab, in the Security Scripting Options section, select all options except the script SQL Server logins (compose SQL Server logon script). Make sure that all of the check boxes in the Table scripting Options (Tables script option) section are selected. The default radio button for both the file format and files to Generate (generated files) is preserved. Finally, when all settings are set correctly, click the OK button to start the script generation process.
You will be prompted to specify a file location. By default, Visual Studio. NET points to the Create Scripts folder in an existing database project. Click the OK button to accept this default location.
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