Replace a Model in AX7 / D365
Like stated in the official Im- / Export Model “Docs” article from Microsoft, we can use the ModelUtil.exe to im- / export and delete models in AX 7. But if you take a detailed look at it, you will see it provides you with another option – replace.
If you look at my try to get help on the command, you will see the replace option:
Why replace a Model?
What is does is a simple delete (it will prompt for confirmation) and then an import in just one statement. Why? I often use it for importing an updated model into an “One Box”, it just saves some time and I only have one command to remember.
How to use it?
The ModelUtil.exe is located inside the “PackagesLocalDirectory\bin” folder. Just cd into and call it with the option -replace, the path to the metadatastore (-metadatastorepath) (the full-path to “PackagesLocalDirectory“) and the full-path to the model you want to import with the -file parameter.
|Usage: ModelUtil.exe -export -metadatastorepath=[path to metadata store] -modelname=[name of the model to export] -outputpath=[path to the folder where the model should be saved]|
|Usage: ModelUtil.exe -import -metadatastorepath=[path to metadata store where model should be imported] -file=[full path to the file to be imported]|
|Usage: ModelUtil.exe -replace -metadatastorepath=[path to metadata store where model should be imported] -file=[full path to the file to be imported]|
|Usage: ModelUtil.exe -delete -metadatastorepath=[path to metadata store] -modelname=[name of the model to delete]|
|Usage: ModelUtil.exe -importxref -file=[path of xref file to import] -server=[sql server] -database=[database name]|
Now, if a model exists which is equal to the model in your linked file, the installed model will be replaced by your given file.