How to: Update an Existing Model Using the -force Option of Mx.exe
[This content is no longer valid. For the latest information on "M", "Quadrant", SQL Server Modeling Services, and the Repository, see the Model Citizen blog.]
In addition to deploying models with Visual Studio 2010, you can also deploy models from command prompt. This topic explains how to update a model by using the force option of the Mx.exe command-line tool.
To update an existing model with the -force option of Mx.exe
Compile any changes to your Microsoft code name “M” model into an image file. For more information, see Compiling "M" Files.
Assuming that the previous version of the model was deployed to the target database, use the force option to uninstall the old image and install the new image. For example, if the new version of the model is contained in an image file, MyModel.mx, use the following command to reinstall this image into the local Repository database:
mx.exe install MyModel.mx –d:Repository –s:(local) -force
Remarks
The force option is the same as uninstalling the target image and reinstalling it. In the previous example the following two commands would have the same result as the force option.
mx.exe uninstall MyModel –d:Repository –s:(local)
mx.exe install MyModel.mx –d:Repository –s:(local)
All database objects associated with an image are dropped and re-added. This is important to understand, because any data in the target tables that is not defined in the image file will be lost during this process. If you have data in the target tables that must be preserved, you manually manually back up and migrate that data after the update.
If an image cannot be uninstalled, the force option will fail. For example, if you add a Pre.sql or Post.sql script file to the image, the Mx.exe tool does not understand how to uninstall the custom Transact-SQL script actions. In that situation, the image cannot be reinstalled. When the image fails to uninstall, you should drop and recreate the database during the development of your model. For more information, see How to: Update an Existing Model by Recreating the SQL Server Modeling Services Database.