How to: Update an Existing Model by Recreating the SQL Server Modeling Services Database
During model and application development, one strategy for updating the model in the database is to drop the database and recreate it. This strategy results in the fewest complications compared to altering the database schema or dropping and recreating individual database objects. The following procedures outline various strategies for updating a model by recreating the database.
In each procedure, an example database named MyDB is used as the target database, which resides on the local instance of SQL Server. After you recreate the target database, you must then install your updated models.
|You do not have to follow all the following procedures. Some models only require an empty database, while other models may require the presence of a system-provided domain, such as System.Identity. Once you identify your specific needs, you could decide to create a batch file that runs all of the commands that setup your target database.|
To drop and recreate an empty database
On the Start Menu, select All Programs, Microsoft SQL Server Modeling CTP, and then click Microsoft SQL Server Modeling CTP Command Prompt.
Use the create command of Mx.exe to create the target database. Also specify the force command, which will drop the target database and recreate it.
mx.exe create /d:MyDB /s:(local) /force
To add SQL Server Modeling Services to the recreated database
First follow the previous steps that explain how to drop and recreate the target database with Mx.exe.
Use Mx.exe to install the Base Domain Library (BDL), which supports the features of Modeling Services. The BDL is part of the Repository.mx image file, which resides in the bin directory of the SQL Server Modeling CTP.
mx.exe install Repository.mx /d:MyDB /s:(local)
To add the SQL Server Modeling CTP domains
First follow the previous steps that explain how to drop and recreate the target database with SQL Server Modeling Services.
Use Mx.exe to install the other system-provided domains for the SQL Server Modeling CTP. These can be installed by their associated image files which resides in the bin directory of the SQL Server Modeling CTP.
mx.exe install Microsoft.UML2.mx /d:MyDB /s:(local) mx.exe install System.Identity.mx /d:MyDB /s:(local) mx.exe install System.Runtime.mx /d:MyDB /s:(local)
To install the updated models using Mx.exe
In the SQL Server Modeling CTP Command Prompt, navigate to the directory with the updated image files.
Use the install command of Mx.exe to install the new versions of your models. The following command shows how to install an image named MyImage.mx into the MyDB database.
mx.exe install MyImage.mx /d:MyDB /s:(local)
Note: Note that after recreating the database, it is also possible to install the updated model by using the deployment features from Visual Studio 2010. For more information, see How to: Update an Existing Model Using Visual Studio.