web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Refresh model using command prompt

(1) ShareShare
ReportReport
Posted on by 10

Hi,

I have a requirement to import, build, sync a model via command prompt and execute a data import job (using entities in the imported model). All of this is called from a c# application. The problem is : i am able to call import, build and sync commands using c# without issues . But when i create and call a data import job, it is not able to find my newly imported objects.

Whereas, when i run a manual build or just refresh model in visual studio and run the same data import- it works fine. Somewhere- import,build and sync via command prompt is not refreshing models successfully. need help on how to refresh models using command prompt

I have the same question (0)
  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Can you share your script? And why do you need to install models? Why not install a deployable package?

    Could you tell us some background - what are you using this process for?

  • WillWU Profile Picture
    22,361 on at

    Hi FaraKather,

    If you are using the modelutil.exe,there is no option to refresh your model, 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.

    ModelUtil.exe
    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]

  • FaraKather Profile Picture
    10 on at

    Hi Nikolas, This is for an internal automation and used only in development environments. Below are the scripts, i am using currently for import/build/sync

    Import script: K:\AOSService\PackagesLocalDirectory\bin\ModelUtil.exe -import -metadatastorepath="K:\AOSService\PackagesLocalDirectory" -file={model file path}

    Build script: K:\AOSService\PackagesLocalDirectory\bin\xppc.exe -metadata="K:\AosService\PackagesLocalDirectory" -modelmodule={model name} -output="K:\AosService\PackagesLocalDirectory\{model}\bin" -referenceFolder="K:\AosService\PackagesLocalDirectory" -log="C:\temp\buildmodelresult.txt" -xmllog="K:\AosService\PackagesLocalDirectory\{model}\BuildProjectResult.xml" -nowarn

    sync script: K:\AOSService\PackagesLocalDirectory\bin\syncmode="fullall" -metadatabinaries="K:\AosService\PackagesLocalDirectory" -connect="Data Source=localhost;Initial Catalog=AxDB;Integrated Security=True;Enlist=True;Application Name=AXVSSDK" -verbosity="Minimal"

  • FaraKather Profile Picture
    10 on at

    Thanks Will. I knew these options earlier, but looking for the one to refresh models

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    In development environments, shouldn't the developers get latest code from the source control? Not by installing models. And if you install models, then you will overwrite any pending changes on those models, that the developers might have.

    Anyway, if you import the models, and build & sync from command line, everything should be fine. Refresh models simply updates Visual Studio's "knowledge" about models. But since you are not in Visual Studio, it should not matter.

    So, can you share more details about "when i create and call a data import job, it is not able to find my newly imported objects." How is this job created? How is the data imported? Do you get some errors?

  • FaraKather Profile Picture
    10 on at

    Create an import job meaning - I make an entry to DMFDefinition group (package based import) and invoke import using RESTAPI call "/data/DataManagementDefinitionGroups/Microsoft.Dynamics.DataEntities.ImportFromPackage".

    i import excels via this package- it uses Enum values. Since the model refresh is not happening properly, the imported excel data is not parsed in staging and hence data import not working.

    Whereas, if i just refresh/build my model again via VS, it easily identifies the enum values and imports

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Somehow I still don't think it's about model refresh. Refreshing models doesn't have any impact on the application functionality. Only the build does.

    We can verify this easily:

    1) Import models via command line

    2) Login to VS, refresh models

    3) Build from command line

    Does it work now?

    I still think that you should never have to install models in a dev system (except if importing models from an ISV provider). Instead the models should be downloaded from source control. Could you tell us how does it really work for you? Are you overwriting all local pending changes each night by importing these models?

  • FaraKather Profile Picture
    10 on at

    Even i believe refresh may not have much impact. but this is the scenario i tried

    1) Imported model via cmd line

    2) Build model via cmd

    3) sync via cmd

    After step3- data import using RESTAPI didnot work

    4) Either refresh model in VS or build model via VS -  then it worked.

    I ll be importing this model into a fresh D365 environment, so no customizations to overwrite. this is once in a while activity

    Basic problem statement: I want to install my model into D365 and load bulk data(using the entities from installed model). Input is in Excel files

  • Verified answer
    Joris dG Profile Picture
    17,775 on at

    Let's lay this out what's going on. Models/source code are just "files". Files are loaded by applications. If an application has the files loaded and you change/add anything outside the application, that application has to be restarted, or somehow triggered to "refresh".

    So, Visual Studio has a "Refresh Models" option because it loads files on startup, and if you change anything outside of VS then you need to tell VS to reload everything (or you can restart VS).

    Then there's the added complication of binaries (DLLs) which are loaded and locked in memory when they're being "run". For example, batch and AOS server load X++ binaries to run - and those files are locked as long as batch and AOS are running.

    In your case, you are likely reaching the AOS to trigger the data import. So first, before you compile do you shut down batch and AOS? Because those would lock any files you're trying to recompile (i.e. your compile doesn't result in anything because it can't overwrite the DLLs). And then of course, you would need to startup the AOS again to reach the URL to trigger the import.

    I like the idea of automating. However, from a source control perspective what you're doing is far from ideal as your source control can't keep track of what version of the files you actually have on your box. Instead of importing models, consider doing "Get latest" from command line instead -so that Visual Studio KNOWS what version of the code you put on the box.

  • FaraKather Profile Picture
    10 on at

    Thanks Joris. I didnot shut down AOS and Batch during compile earlier. let me try this option and revert back.

    Since this is a POC kind, its independent of source control. Will integrate it in a later point

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 663 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 540 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 348 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans