AddXXX() / AddHostXXX() methods

Problem

It is not clear what is the different between AddXXX() and AddHostXXX() methods.

Explanation

Once M2 model gets provisioned, all non-existing artifacts get created, and all existing artifacts get updated. All model nodes are built with .AddXXX() method.

Sometimes we don't want to update or change artifacs: for instance out of the box artifacts such as Pages list, SitePages list. In that case use .AddXXX() method for non-existing artifacts, and use .AddHostXXX() method for artifacts which either come with SharePoint or already exist.

Solution

  • Use AddXXX() methods on non-existing artifacts
  • Use AddHostXXX() method on existing, out of the box artifacts.