Recently I came across a situation where I had multiple models with the same name in one of the AX 2012 instances I am developing for. It is possible to do this through the AX developer workspace as long as they have different publishers, but it causes the model management Powershell cmdlets to freak out a bit.
Recently I came across a situation where I had multiple models with the same name in one of the AX 2012 instances I am developing for. It is possible to do this through the AX developer workspace as long as they have different publishers, but it causes the model management Powershell cmdlets to freak out a bit.
In my case, I wanted to delete one of the models so I would not have duplicate names, but when I tried to use Uninstall-AXModel, I got an error message saying:
uninstall-axmodel : The pipeline has been stopped. At line:1 char:1 uninstall-axmodel -server DEVSRV -database DynamicsAX_Dev_model -m …~~~~~~~~~~~~~~~~~ CategoryInfo : OperationStopped: (:) [Uninstall-AXModel], PipelineStoppedException FullyQualifiedErrorId : Multiple models exist with the name temp.,Microsoft.Dynamics.AX.Framework.Tools.ModelManagement.PowerShell.UninstallAXModelCommand
So… What to do? The documentation only refers to the -Model parameter being a string, and what I could find online just says this should be the name of the model.
A hint to the solution was to be found in the usage text for the old-style axutil command. It mentions being able to use a model ID instead of a model name:
/model:{model-name | '(' model-name , publisher')' | model-id} Specifies one model in the model store. The model can be identified by: * Name - name that uniquely identifies exactly one model in the store. * Two-part unique name - values must be contained in parentheses, and comma separated. * ID - the model store specific number which can be found using the list command. Example: axutil exists /model:Test /db:axmodelstore /server:axserver
Solution
So, use Get-AXModel to list the models matching the name you want to delete:
get-axmodel -server devsrv1 -database dynamicsax_dev_model -model temp
Find the ModelId property of the model you want to delete:
ModelManifestType : AXModelFile ModelHash : BackingFile : ModelFileVersion : 18 SchemaVersion : 1.9 ElementCount : 2 ModelBuildVersion : ModelId : 25 Name : temp DisplayName : temp Description : Publisher : Signed : False Category : Standard InstallMode : Standard Version : 1.0.0.0 Layer : Usr DependencyState : Details :
To remove that specific model, just pass the model ID to the -Model parameter of Uninstall-AXModel:
uninstall-axmodel -server devsrv1 -database dynamicsax_dev_model -model 25