While getting introduced to development in Dynamics 365 for Finance and Operations, I found myself in a situation of adding/removing a model. There is a helpful tool we can use called “modleutil.exe”. This executable can be levied to accomplish a multitude of possibilities such as, import, delete, replace, and export.
In order to use the modelutil.exe to delete a model name, you first need to know where the modelutil.exe is located. Navigate to the AOSService folder, drill down in the PackagesLocalDirectory and its bin folder. The modelutil.exe is best used in a shell, which is a program that allows a command-based interface to the system’s kernel. Use CMD.exe or PowerShell.exe.
Working in the solution, I came across an issue that resulted in a harsh lesson. I made a model that I later did not need, only to find that the name was taken when I wanted to create a new model. For this instance, I created a model named Model1. I could not reuse the name Model1. Because modelutil.exe was not fully understood, I dug into the file structure. I recommend that you should not do that.
When using the modelutil.exe, you must understand some details. First, the exe requires you to use a command line tool, like command prompt. In a command line tool run the “modelutil.exe /?” this will display the following text.
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]
If you notice, there are five different options to choose from: export, import, replace, delete, and importxref. Each of those options has further requirements. For the metadatastorepath, you will need the path to the PackagesLocalDirectory. For the modelname, you’ll need the model’s name.
The case that I described above will require the fourth option, the ‘-delete’ option. Once I deleted the previous model, I was able to continue to create a new Model1 model in Visual Studio.