Keep Your Dataverse Solution Clean and Simple

Solutions are used to transport table metadata, apps, automations and other components from one environment to another in Dataverse or Power Platform projects. It is important to keep the solutions as simple as possible to improve the solution import time and to avoid unexpected behaviour in the target environment. The rule of thumb is to include only the components that are created/updated in that environment which are unmanaged components or managed components with unmanaged layer (due to being updated in that environment).

Do not Include All ObjectsThe first point is simple. When you add an existing table to the solution, do not check "Include all objects" (unless there is a specific reason or you created that table in another solution and intend to add the whole table in this solution as well). "Include table metadata" can also be left unchecked unless the table metadata (Enable Audit, Duplicate Detection, Quick Create, etc.) is being updated. By clicking the "Select objects", you can add the sub-components that are created/updated.


Do not Add Required ObjectsDo not use "Add required components" to avoid unexpected consequences since it could add a lot more unrelated components to the solution unnecessarily. You can read more details at Alex Shlega's blog post here.


Even if you avoid the actions above, there are some scenarios that the system may add related components to the solution, so be cautious not to let the system automatically add unnecessary components.
Do not Include Missing Required ComponentsFor those who are still using the classic solution explorer for any reason, always choose the "No, do not include required components." option in the "Missing Required Components" dialog. Choosing "Yes, include required components." may cause unexpected consequences as point above. You don't have to worry about that if you only use to modern solution explorer to add the components to the solution.


Adding Relationship and Related TableWhen you create/update a relationship between tables OR create a lookup column (which creates a relationship as a result) in the solution, make sure that the other table of the relationship is in the solution too. If the other table is not in the solution, you can add just the table without any component (as mentioned in the first point of this post).
e.g. if you have a Table A in the solution and you need to
  • create a lookup column to Table B OR
  • update a many-to-many relationship to Table B
but the Table B is not part of the solution yet. In that case, before creating/updating those lookup/relationship, it is better to add the Table B to the solution manually with "Include all objects" unchecked.

Otherwise, the system will automatically add that missing table (Table B in the above example) to the solution upon the creation/update of the relationships. When the system automatically add the table to the solution, only a table without any sub-component is added sometimes (which is fine). But sometimes, a table is automatically added with all objects and that is the situation that we want to avoid by adding the table to the solution manually beforehand. You can read more details at Power Platform & Dynamics CRM Tip Of The Day Tip #714.

Adding Form and Related Business RulesWhen the existing form of the table is added, the Business Rules related to that form are automatically added. If those Business Rules are not modified and not required to be in that solution, those should be reviewed and removed after adding the form.
Mobile Offline Profile and Dependent ComponentsThis one is a bit tricky and it needs to be handled depending on the solution management strategy. In short, When a solution containing a Mobile Offline Profile is exported, the system automatically adds the dependent components of the tables (from the Mobile Offline Profile) into the solution without any confirmation. (you can read more details in my blog post). As I mentioned in the blog post, one of the workaround solution is to use a Data Transporter tool or a PowerShell script in the pipeline to deploy the mobile offline profile data.But if the team's policy is to deploy the mobile offline profile as a solution component, the team needs to review the solution segmentation approach. The Mobile Offline Profile needs to be in the same solution as the other components that the offline profile is automatically adding to the solution.

In the scenario above, the Mobile Offline Profile is deployed as a separate managed solution from the managed solution which contains the table metadata (and forms, views, etc.). Due to the system automatically adding the dependent components upon exporting of Mobile Offline Profile solution, there are some table components in the Mobile Offline Profile solution and there is a multiple solution layers for some of those tables. When the new version of Table Solution 1.1 is imported, the changes are not reflected for those overlapped components because the updates are only installed to the Table Solution layer below.
If the table with all assets are added to the solution unnecessarily by the system by any chance, you can fix it by using Solution Table Integrity Manager tool by Tanguy. (as commented by one of the readers below and thanks for the recommendation too, Parvez Ghumra). With that tool, you can select all the faulty tables (e.g. managed tables with all components) and apply the Fix 1 (remove the managed tables and re-add the unmanaged components only) OR Fix 2 (remove the managed tables and re-add the unmanaged components + managed components with active layer which are modified in the current environment).


Do you have any other tips to keep the solutions clean? Or can you think of any other scenario where the system automatically add the components to the solution? Please leave a comment below to share with the other readers.

Comments

  1. Good one Linn. XrmToolBox also has a tool to check the solution to see if it follows best practice. https://www.linkedin.com/pulse/new-xrmtoolbox-tool-solution-table-integrity-manager-tanguy-touzard-mcpae

    ReplyDelete
    Replies
    1. Really appreciate for the recommendation of the tool, Parvez. I have updated the blog post with your tips. 😉

      Delete
    2. Thanks Linn. But the above comment was not submitted by me. I was just agreeing with it in my comment on your LinkedIn post. Thanks for the mention though 😃

      Delete
    3. Oh, I see. I just misunderstood your comment on LinkedIn 😅

      Delete
  2. Thanks, Linn - avoiding using the "add required components" suggestion is new to me, when the solution is small its can be simple to see what components are added, but for larger solutions you definitely lose some control/visibility over what gets added.

    ReplyDelete
    Replies
    1. That's right, Sarah. And by asking the system to add, it could add a lot more unrelated components to the solution unnecessarily.

      Delete

Post a Comment

Popular Posts