Models and packages

This article describes the concept of models and packages. It also explains how to use the development tools in Microsoft Visual Studio to create new models, update the parameters of existing models, and visualize dependencies between models.

To work with models in the model store, use the tools in Microsoft Visual Studio. You can create new models and change parameters for existing models.

Conceptual overview

A model is a group of elements, such as metadata and source files, that typically constitute a distributable software solution and include customizations of an existing solution. A model is a design-time concept, for example a warehouse management model or a project accounting model. A model always belongs to a package. A package is a deployment and compilation unit of one or more models. It includes model metadata, binaries, and other associated resources. You can package one or more packages into a deployable package. A deployable package is the vehicle used for deployment on runtime environments.

Creating a new model

Use the Create model wizard to create new models. Access this wizard from Model Management on the Dynamics 365 menu. You can create two types of models:

  • A model that you deploy in its own package – Use this type of model to create new model elements, and extend the metadata and business logic of referenced models. The wizard lets you select the referenced models. This type of model is compiled into its own assembly and binaries. It simplifies and reduces the cost of upgrades, deployment, and application lifecycle management.
  • A model that is part of an existing package – Use this type of model to temporarily use legacy features such as overlayering source code and metadata. This feature is considered legacy and is supported only to upgrade from legacy versions.

In the Create model wizard, select usr for the layer. This layer stores user customizations. If needed, you can patch your customizations by using the usp layer. If there are multiple versions of the same object in different layers, the top layer takes precedence and is used.

When you complete the Create model wizard, if you choose to create a new project, you're prompted to specify a name and location for it.

Updating model parameters

If you need to change the parameters for a model, use the Update model parameters dialog box.

  1. On the Dynamics 365 menu, point to Model Management, and then select Update model parameters.
  2. In the Model name field, select the model to update parameters for.
  3. Update the parameters as needed.
  4. Select Next.
  5. Update the dependency information for the current model, if changes are required.
  6. Select Next. The summary information for the model is displayed.
  7. Select Finish.

The updated model parameters take effect only after you restart Visual Studio.

Viewing package dependencies

You can create a graphical representation that shows which packages and their models have dependencies on other packages. On the Dynamics 365 menu, point to Model Management, and then select View package dependencies. A Directed Graph Markup Language (DGML) diagram is generated for the current packages and their models. This diagram is a collection of interdependent nodes, each of which represents a package. Each node lists all the models that belong to that package. Use the additional tools to enhance or simplify the diagram. For example, you can add comments, move nodes around, or remove nodes. You can also view package dependencies of a single model by following these steps:

  1. Make sure the Application Explorer is in Model view: Right-click the AOT node and select Model view.
  2. Right-click on any model and select View package dependencies > View outgoing references.

This process generates a graph of all packages that the selected model depends on.

Screenshot of the View dependencies diagram.

Screenshot of the Directory dependencies diagram.

Deleting a model

The procedure you should use for deleting a model depends on whether you use a unified developer environment or a local development environment. Both methods are described in the following sections.

Delete a model from a unified developer environment

Deleting a local model folder doesn't remove the model from the cloud runtime. Use Delete Models from Online Environment in Visual Studio to remove custom packages from the connected unified developer environment.

Although the command name refers to models, you select packages for deletion. Removing a package removes all the models in that package from the online environment, not just an individual model.

To delete a model from a unified developer environment, follow these steps:

  1. In Visual Studio, select Tools > Connect to Dataverse, and connect to the unified developer environment that contains the models to remove.
  2. Select Extensions > Dynamics 365 > Configure Metadata, and verify that the active configuration includes the packages to remove and their dependencies. Packages can be in Folder for your own custom metadata or Folders for reference metadata.
  3. Select Extensions > Dynamics 365 > Deploy > Delete Models from Online Environment.
  4. In the Delete packages from online environment dialog, use the search box under Packages to find each package, and select its checkbox.
  5. Review Referencing Packages. Select every package that references a selected package, including any further referencing packages, so that the full dependency chain is selected. The Delete button is available only when at least one package and all its referencing packages are selected. If you need to keep a referencing package, close the dialog, remove its dependency, build and deploy the updated package, and then retry.
  6. Review the complete selection, and select Delete to start the operation. The dialog closes after submitting the request. Closing the dialog doesn't mean that deletion has finished.
  7. Open the Output window, and select FinOps Cloud Runtime to monitor progress. Wait for the operation to complete successfully before starting another operation. If it fails, review the messages and the operation logs linked from the output.
  8. Run database synchronization separately. The deletion command doesn't request database synchronization. Select Extensions > Dynamics 365 > Synchronize Database to synchronize all remaining models, and wait for synchronization to complete.
  9. Open the finance and operations app, and verify that the remaining customizations work as expected.

If the dialog shows No custom extension packages are available., check the active metadata configuration and the package folders on your development computer.

For more information about connections, metadata configurations, and operation logs, see Workflow to write, deploy, debug, and troubleshoot X++ code across multiple environments.

Delete a model from a local development environment

The following steps assume the local model store folder is C:\AOSService\PackagesLocalDirectory and your model is named MyModel1.

If your model belongs to its own package, such as an extension package with no other models in the package, to delete it, follow these steps:

  1. Close all instances of Visual Studio.
  2. Stop the following services: AOS web service and Batch Management service.
  3. Delete the package folder C:\AOSService\PackagesLocalDirectory\MyModel1. On cloud-hosted environments, this folder might be located on another drive letter such as K:.
  4. Restart the services that you stopped in step 2.
  5. In Visual Studio, perform a full database synchronization (Visual Studio > Dynamics 365 > Synchronize database).

If your model belongs to a package with multiple models, such as when MyModel1 overlays Application Suite:

  1. Close all instances of Visual Studio.
  2. Stop the following services: AOS web service and Batch Management service.
  3. Delete the model folder C:\AOSService\PackagesLocalDirectory\<PackageName>\MyModel1. In this example, it's PackageName=ApplicationSuite. On cloud-hosted environments, this folder might be located on another drive letter such as K:.
  4. Remove the descriptor file for the model in C:\AOSService\PackagesLocalDirectory\<PackageName>\Descriptor\MyModel1.xml. On cloud-hosted environments, this folder might be located on another drive letter such as K:.
  5. Restart the services that you stopped in step 2.
  6. In Visual Studio, build the package that the deleted models belonged to (Visual Studio > Dynamics 365 > Build models).
  7. In Visual Studio, perform a full database synchronization (Visual Studio > Dynamics 365 > Synchronize database).

Additional resources

Development tools in Visual Studio

Develop and customize home page

Export and import models