Monday, January 25, 2016

Creating and deleting the model from Microsoft Dynamics AX 7


In my last post, We got our AX 7 VM. In this post I am going to explain how to create a model.
To create a model, We have to navigate to 'Dynamics AX 7' menu -> Model Management -> Create Model..


This will open up a wizard for creation of model.
Now In AX 7, there are 2 approaches for the development.

  • Extension approach -> This is the recommended approach. It creates separate assemblies for the elements of the model. Advantage is that it requires virtually no upgrade efforts when new product versions are released. But it has some limitations, We will discuss those in later posts 
  • Customization approach -> This is similar to over-layer approach which is followed in AX 2012 or earlier versions. It will update the same assemblies in the same package. When it comes to upgrade, this requires quite a lot of efforts 

Model creation for extension approach

When you are creating a mode, you need to decide which approach you are going to take. Let see how to create extension model first.
When the wizard is opened, you have to provide Model Name, publisher, Layer, Version, Description and ModelDisplayName(This will be shown everywhere in the visual studio).



I Prefer to keep the name as <Model>Extension. Here I am creating extension model for Application Suite.
Click Next.

Select whether to create model as an existing package or create new package. For Extension approach, you will have to select create new package. Click next.

Select the referenced packages. It is important to reference appropriate models. You can create extensions of the elements which belongs to these selected packages.
There are 2 approaches for models here.
  • You can create extension model per original model. For example ApplicationSuiteExtension model for ApplicationSuite and LedgerExtension for Ledger Model
  • You can create one extension model for all the extension objects. For example VINExtension model for both ApplicationSuite and Ledger model. In this case you reference to all models from which you need elements.
I personally prefer creating extension model per original model. Here I am selecting Application Suite model as reference model. (I could not select Application Platform in this form, there is option to update model later. In that option you can change the referenced models)

Review the summary screen and click on Finish. If the Create new project checkbox is checked, New screen for creating new project will be launched.

Give name to project same as model (recommended). Either create a new solution or you can add project to existing solution.

This will create new project. Now you can add elements to project and start customization.

Model creation for Customization approach:

When the wizard is opened, you have to provide Model Name, publisher, Layer, Version, Description and ModelDisplayName(This will be shown everywhere in the visual studio).


I Prefer to keep the name as <Model>Custom. Here I am creating customization/overlayer model for Application Suite.
Click Next.



Select whether to create model as an existing package or create new package. For customization approach, you will have to choose select existing package. Click next.


On this step you will see the difference. When you create new package, you get option to select the reference models, but when you add to existing package, you do not get to select the reference packages. As you see in the above screenshot, there are few reference packages already selected. I guess these are same as the original model which created this package. Finish the review and click on finish



Give name to project same as model (recommended). You have to create new solution here which is different from our first project where we had option to use the existing solution.

This will create new project. Now you can add elements to project and start customization.

In AX7 there is no database for the model. Model and elements are stored in XML format in the file system. These new models will be created under C:\Packages
For extension model, New folder is created under Packages folder. But for Customization model, new folder is created under the existing package.

Description of each model is stored under the Descriptor folder.


It is good to know these details, but refrain from making any changes to these files directly. You should always edit from Visual studio.

Deleting model:

I could not find any way to delete the model from Visual studio but you can directly go into the explorer and delete following things:
  • Solution created for the project(model)
  • For Extension model, Package folder created for that extension model.
  • For Customization model, folder created for the model under existing package and the descriptor xml file for the model.
Beware that I could not find any documentation anywhere but found it via experience. This may not be correct way and it may create unexplored problems

P.S.: When you look the model structure under Application suite, it is different from the rest of the models. This needs to be further studied more. This is tried on AX 7 CTP 8 version.

2 comments:

  1. It seems that when you create a model from an existing package say Application Suite (customization approach) you cannot reference any other packages (say Application Platform) in that same model. You need to create a new model (and a new project under that model) for that purpose. Is that true?

    ReplyDelete
    Replies
    1. In customization approach, I have seen that with OOB models, You can reference only those Models which are referenced by parent model. But if you create a new model(lets say TestParent) and then create a customization model(TestChild), you can update the references of the both models independent of each other.

      Delete