We have done all our up front work to prepare for our first deployment. We are now ready to actually create the database!
Before we begin the build and deploy, let's make sure output is visible so we can the results of our actions.
We choose Build DemoDB from Build.
The output window shows that we've built our project into a .dbschema file. This is an important file as it contains all the objects that make up our data model. It is used by the deployment process to compare against any existing database and to update the target database as needed. If the target database doesn't exist, naturally, the database is created with the defined objects.
Examining the file system, we see that Visual Studio built the following files:
Now that the .dbschema file has been created, we can finally create the database! We choose Deploy DemoDB:
The output shows that our objects have been created and our seed data populated. Note that Visual Studio kept track of object dependencies and ensured objects were created in the proper order. Also note that the post deployment script ran after the deployment occurred.
Let's re-examine the scripts in the file system. We now see a script file called DemoDB.sql has been produced by the deploy. This is the auto generated master .sql file I mentioned earlier that contains pre-deployment SQL, the deployment SQL of new/changed/dropped objects, and post deployment SQL. This script was executed against our SQL Server instance by Visual Studio.
Examining SQL Server Management Studio, we see our database and it's objects have been created!!