Step1. To specify databases to deploy
In Solution Explorer, select the project name and then select Properties.
In the Properties page, click the Package/Publish SQL tab.
The Package/Publish SQL tab is displayed, as shown in the following illustration:
You can specify the databases to deploy. In the Database scripting options drop-down list, specify whether you want the scripts that are automatically generated for this database to duplicate only the database structures (Schema Only), to duplicate both the structures and the data (Schema and Data), or to duplicate only the data (Data Only) in the destination environment.
Here, we select "Pull data and/or schema from an existing database" and "Schema and Data".
Step2. To redeploy a database by using automatically generated scripts
After you have deployed a database by using automatically generated scripts, you might make database changes and then redeploy the database. In that case, the deployment process must drop existing database objects before the objects are re-created.
Edit the project file to set the ScriptDropsFirst attribute of the PreSource element of the automatically generated script to True:
Use Windows Explorer to navigate to the project directory, and then open the .csproj or .vbproj file by using Notepad or another text editor. (You can find the path to the project folder in the Project Folder field of the Properties window.
add the ScriptDropsFirst attribute to the PreSource element, as shown in the following example:
<
PublishDatabaseSettings
>
<
Objects
>
<
ObjectGroup
Name
=
"ApplicationServices-Deployment"
Order
=
"1"
>
<
Destination
Path
=
""
/>
<
Object
Type
=
"dbFullSql"
>
<
PreSource
Path
=
"..."
ScriptSchema
=
"True"
ScriptData
=
"False"
ScriptDropsFirst
=
"True"
CopyAllFullTextCatalogs
=
"False"
/>s
<
Source
Path
=
"..."
Transacted
=
"True"
/>
</
Object
>
</
ObjectGroup
>
</
Objects
>
</
PublishDatabaseSettings
>
More Info
http://msdn.microsoft.com/en-us/library/dd465343.aspx
http://msdn.microsoft.com/en-us/library/ff398069(v=vs.100).aspx
http://msdn.microsoft.com/en-us/library/dd465337.aspx
Article ID: 1683, Created: July 21, 2014 at 2:34 AM, Modified: January 4, 2017 at 10:34 PM