Microsoft had introduced the Model concept in Dynamics AX 2012, in order to help customers more easily to install and maintain multiple solutions side by side in same layer. It is recommended to use models and the model store to deploy customizations or entire solutions. Model management should be very well known topic for build managers but sometimes developers need to do the same task for any purpose.
For that purpose, our team made instructions using two command-line tools:
- Windows PowerShell
- AXUtill
How to create an empty model that has default manifest properties
(AXUtil)
On the Start menu, click Command prompt.
Navigate to the directory for the management utilities. Typically, the location of this directory is %ProgramFiles%\Microsoft Dynamics AX\60\ManagementUtilities.
At the command prompt, type the following command, and then press ENTER.
axutil create /model:<ModelName>/layer:<LayerName>
(Windows PowerShell)
On the Start menu, click All Programs -> Administrative Tools -> Microsoft Dynamics AX Management Shell .
At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
New-AXModel –Model <ModelName> -Layer <LayerName>
How to Export a model
(AXUtil)
On the Start menu, click Command prompt.
Navigate to the directory for the management utilities. Typically, the location of this directory is %ProgramFiles%\Microsoft Dynamics AX\60\ManagementUtilities.
At the command prompt, type the following command, and then press ENTER.
axutil export /model:<modelname> /file:<filename> /verbose
(Windows PowerShell)
On the Start menu, click All Programs -> Administrative Tools -> Microsoft Dynamics AX Management Shell .
At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
Export-AXModel -Model <ModelName> -File <FileName.axmodel>
These commands export the model to an .axmodel file
How to Uninstall a model
(AXUtil)
On the Start menu, click Command prompt.
Navigate to the directory for the management utilities. Typically, the location of this directory is %ProgramFiles%\Microsoft Dynamics AX\60\ManagementUtilities.
At the command prompt, type the following command, and then press ENTER.
axutil delete /model:<name>
(Windows PowerShell)
On the Start menu, click All Programs -> Administrative Tools -> Microsoft Dynamics AX Management Shell .
At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
Uninstall-AXModel –Model <ModelName>
It is recommended to perform this action only if the intention is the model to be permanently removed.
But if the goal is to upgrade a model or replace a model with newer version, it is better to import the model over the existing model, because element IDs and element handles are assigned at installation. If you delete a model, and then import the same model or a model with newer version, element IDs and element handles are randomized, and that affects data integrity.
How to Import a model
(AXUtil)
On the Start menu, click Command prompt.
Navigate to the directory for the management utilities. Typically, the location of this directory is %ProgramFiles%\Microsoft Dynamics AX\60\ManagementUtilities.
At the command prompt, type the following command, and then press ENTER.
axutil import /file:<filename> /verbose
(Windows PowerShell)
On the Start menu, click All Programs -> Administrative Tools -> Microsoft Dynamics AX Management Shell .
At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
Install-AXModel –File <FileName.axmodel> -Details
These commands install the specified .axmodel file in the same layer that it was exported from.
When you import a model, elements in the model that you are importing may conflict with another model in the same layer or may conflict with overlaying version for these elements in upper layer. These conflicts must be resolved. There are several ways to resolve the conflicts occurred during the model import process, and we will write about it too.
When you install or uninstall a model, it is recommended, before taking the action, to create a backup of the database and after the performed action you can run a full compile, synchronize the database and generate Full CIL.