How to Import and Export Models in D365 F&O: A Step-by-Step Guide

If you are working as a developer in Dynamics 365 Finance and Operations (D365 F&O), you will eventually need to move your code from one development environment to another.

To do this, we use something called Models. Think of a model as a "package" that holds all your custom code and designs. In this blog, I will show you the simplest way to export these packages and import them into a new environment using PowerShell.

Step 1: How to Export a Model

Exporting means taking the code out of your current machine and saving it into a single file (called an .axmodel file).

Open PowerShell (Admin).

Go to the folder where the D365 tools are kept. Usually, it is here: C:\AOSService\PackagesLocalDirectory\bin or 

K:\AOSService\PackagesLocalDirectory\bin 

Type this command (change the names to match your project):

PowerShell

.\ModelUtil.exe -export -metadatastorepath=K:\AosService\PackagesLocalDirectory -modelname=Gau_CustModel -outputpath=C:\Temp\

modelname: This is the name of your specific project.

outputpath: This is where you want to save the file on your computer.

Snap - 



Step 2: How to Import a Model

Importing means taking that .axmodel file and adding it to a new development machine.

Open PowerShell (Admin) on the new machine.

Go to the same bin folder as before.

Type this command:

PowerShell

.\ModelUtil.exe -import -metadatastorepath=K:\AosService\PackagesLocalDirectory -file=C:\Temp\Gau_CustModel.axmodel

file: This is the location of the file you want to bring in.


Step 3: What to do After Importing?

Once the black screen finishes running the command, you aren't quite done. You need to tell Visual Studio that new code has arrived:


Open Visual Studio.


Go to the top menu: Dynamics 365 > Model Management > Refresh Models.


Build your model: Right-click your project and select "Build."


Sync Database: Run a "Database Synchronization" to make sure the tables are ready.


Summary

Moving code doesn't have to be scary! By using these simple PowerShell commands, you can safely move your work between environments without losing any data. This method is much faster than copying files manually and helps keep your development environment clean. Even if you are a beginner, mastering these steps will help you work like a pro and collaborate better with your team.

Comments