Tuesday 21 April 2015

Model and Model Store in ax 2012

Basic Info:

Models were introduced in Microsoft Dynamics AX to help partners and customers more easily install and maintain multiple solutions side by side in the same layer. This topic introduces the concept of models, and describes how models relate to layers and label files. This topic also describes the model store, which is the part of the Microsoft Dynamics AX database in which models are stored.
Models:
model is a set of elements in a given layer. Each layer consists of one or more models. Each layer contains one system-generated model that is specific to that layer. Every element in a layer belongs to only one model. In other words, no element can belong to two models in the same layer, and every element must belong to a model.
A model is permanently associated with the layer that is created in. If you need to move one of your models from one layer to another, you must create a project from the model in the AOT, export the project as an xpo file, create a target model in the desired layer, delete the original model to avoid having to resolve layer conflicts, and import the xpo file to the target model. If you are moving elements between models in the same layer, you can use the Move to model command in the AOT.
ModelStore:
Models are stored in the model store. The model store is the part of the Microsoft Dynamics AX database in which all application elements for Microsoft Dynamics AX are stored. Customizations are also stored in the model store. The model store replaces the Application Object Data (AOD) files that were used in earlier versions of Microsoft Dynamics AX. Models that have been installed in the model store are used at run time.
Note: Models can be exported to files that have the .axmodel extension. These files are called model files. Model files are deployment artifacts. Model files can be signed with strong name signing and Microsoft Authenticode signing.
How to manage Label files with Model:
In Microsoft Dynamics AX 2012, label files, or ALD files, are part of models. A label file must be added to a model before the model can be installed. After a model has been installed, ALD files are pulled from the model store to the local of Application Object Server (AOS) instance when the AOS is started. When the AOS is shut down, the ALD files are pushed back to the model store.
ALD files from earlier versions of Microsoft Dynamics AX are not part of a model file. However, you can import these files into the model store from the Label Files section of the Application Object Tree (AOT). Use the Create from file shortcut command.
Note: The ALD file from an earlier version of Microsoft Dynamics AX must not be located in the application folder of AOS. Otherwise, you cannot import the file.

Working with label files across solutions

It is recommend that you use one label file per solution to simplify installation.
If you find that you require multiple label files, it is recommend that you create a single shared, cross-solution label file and package it as a model file. Then, when you install solutions, you must install two models: the solution itself and the label model.
If you want to ship additional languages, you can add the languages to the solution model, increment the model’s version number, and then re-import the model.

Export an .axmodel file (Windows PowerShell)

  1. On the Start menu, point to All Programs, point to Administrative Tools, and then click Microsoft Dynamics AX Management Shell.
  2. At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
    Export Command Syntax :
    Export-AXModel –Model <name> -File <Filename.axmodel>
    Example :
    Export-AXModel –Model SecurityModel -File C:\SecurityModel.axmodel
Import an .axmodel file (Windows PowerShell)
    1. On the Start menu, point to All Programs, point to Administrative Tools, and then click Microsoft Dynamics AX Management Shell.
    2. At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
    Import Command Syntax :
    Install-AXModel -File <Filename.axmodel> -Details
    Exmaple :
    Install-AXModel -File C:\SecurityModel.axmodel -Details
Exporting a Model with AXUtil.exe
To export a model by using AXUtil.exe follow these steps.
  1. Click Start > All Programs > Accessories and right-click Command Prompt selecting Run as administrator.
  2. Change directory to “\Program Files\Microsoft DynamicsAX\60\Server\MicrosoftDynamicsAX\Bin” or to the bin directory for your server installation.
  3. Type “AxUtil.exe export/file:<path to save your model>.axmodel/model:<model name>” and then press Enter to export the model.
Importing a Model with AXUtil.exe
To import a model by using AXUtil.exe follow these steps.
  1. Click Start > All Programs > Accessories and right-click Command Prompt selecting Run as administrator.
  2. Change directory to “\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\Bin” or to the bin directory for your server installation.
  3. Type “AxUtil.exe import /file:<path to where you saved your model>.axmodel and then pressEnter to import the model.
The model store that you export remains in the original environment. The model store is not deleted.

Export a model store (Windows PowerShell)

  1. On the Start menu, point to All Programs, point to Administrative Tools, and then click Microsoft Dynamics AX Management Shell.
  2. At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
    Export-AXModelStore -File <Filename> -Details
    
    This command exports the model store to an .axmodelstore file.
    For more information, see Export-AXModelStore.

Export a model store (AXUtil)

  1. On the Start menu, click Command prompt.
  2. Navigate to the directory for the management utilities. Typically, the location of this directory is %ProgramFiles%\Microsoft Dynamics AX\60\ManagementUtilities.
  3. At the command prompt, type the following command, and then press ENTER.
    axutil exportstore /file:filename [/verbose]
    
    This command exports the model store to an .axmodelstore file.
When you import a model store, you can import the new model store directly to the default schema, dbo. Alternatively, you can import the model store to a different schema, and then apply the model store to the default schema.
  • If you import the new model store directly to the dbo schema, downtime is likely to be greater, because you must stop all Application Object Server (AOS) instances while the model store is imported.
  • If you import the model store file to a non-default schema, downtime may be less, because AOS instances can remain active throughout the import process.
AOS instances must be stopped when the new model store is applied to the default schema. However, less time is required to stop an AOS instance than to import a model store.
When you import a model store, you can back up the existing model store to another schema. The schema that you back up the model store to cannot exist before you import the model store.
By default, if a conflict of element IDs occurs while an .axmodelstore file is imported, the import is stopped.
By default, optimization steps are performed if the number of elements in a model increases by more than 50 percent when a model or model store is reimported. For more information, see How to: Optimize a Model Store for Runtime.

Import a model store to the dbo schema (Windows PowerShell)

  1. Drain all client connections from the AOS instance that you are working with. For more information, see Drain users from an AOS.
  2. At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
    Import-AXModelStore -File <Filename> 
    
    This command imports a model store to the Microsoft Dynamics AX database and associates the model store with the default schema, dbo. You can also use the -BackupSchema parameter to copy the model store that is overwritten to a new schema. The schema that is specified by the -BackupSchema parameter cannot exist at the time that you run the cmdlet.
    For more information, see Import-AXModelStore.

Install a model store to the dbo schema (AXUtil)

  1. Drain all client connections from the AOS instance that you are working with. For more information, see Drain users from an AOS.
  2. On the Start menu, click Command prompt.
  3. Navigate to the directory for the management utilities. Typically, the location of this directory is %ProgramFiles%\Microsoft Dynamics AX\60\ManagementUtilities.
  4. At the command prompt, type the following command, and then press ENTER.
    axutil importstore /file:filename
    
    This command imports a model store to the Microsoft Dynamics AX database and associates the model store with the default schema, dbo. You can also use the /BackupSchema parameter to copy the model store that is overwritten to a new schema. The schema that is specified by the /BackupSchema parameter cannot exist at the time that you run AXUtil.

Import a model store to a temporary schema, and then apply the model store (Windows PowerShell)

  1. For this example, the non-default schema is named TemporarySchema.
    At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
    Import-AXModelStore -File Staging.axmodelstore -SchemaName TemporarySchema
    
    This command installs the model store file in the schema that you specify.
    NoteNote
    The model store that you import to the non-default schema is not visible to Microsoft Dynamics AX.
  2. After the model store has been imported, drain all client connections from the AOS instance that you are working with. For more information, see Drain users from an AOS.
  3. After all AOS connections have been closed, type the following command, and then press ENTER.
    Import-AXModelStore -Apply:TemporarySchema
    
    This command applies a model store that was associated with the non-default schema, TemporarySchema, to the dbo schema. The model store then becomes visible to Microsoft Dynamics AX.
    For more information, see Import-AXModelStore.

Install a model store to a temporary schema, and then apply the model store (AXUtil)

  1. For this example, the non-default schema is named TemporarySchema.
    On the Start menu, click Command prompt.
  2. Navigate to the directory for the management utilities. Typically, the location of this directory is %ProgramFiles%\Microsoft Dynamics AX\60\ManagementUtilities.
  3. At the command prompt, type the following command, and then press ENTER.
    axutil importstore /file:filename /schemaname:name /verbose
    
    
    This command installs the model store file in the schema that you specify.
    NoteNote
    The model store that you import to the non-default schema is not visible to Microsoft Dynamics AX.
  4. Drain the client connections that are connected to the AOS instance that you are working with. For more information, see Drain users from an AOS.
  5. At the command prompt, type the following command, and then press ENTER.
    axutil importstore /apply /schemaname:TemporarySchema /verbose 
    
    This command applies a model store that was associated with the non-default schema, TemporarySchema, to the dbo schema. The model store then becomes visible to Microsoft Dynamics AX.

1 comment:

  1. I tried exporting the AX Model store by using both MS Dynamics AX Management Shell and AXUtil. Both export the model store successfully, however I noticed a file size difference between the two (around 4KB difference). Do you see any reason why the file sizes are different?

    ReplyDelete