Cannot find model handler for type XXX

Problem

M2 seems to not be able to find a correct model handler for the giving definition

Explanation

SharePoint comes in several editions: Foundation, Standard and Enterprise. Every SharePoint version has a set of APIs along with a set of assemblies.

M2 comes in several flavours as well:

  • SPMeta2.CSOM.Foundation
  • SPMeta2.CSOM.Standard
  • SPMeta2.SSOM.Foundation
  • SPMeta2.SSOM.Standard

Each SharePoint API is wrapped by M2 into either "Foundation" or "Standard" package, so that you can build apps for SharePoint Foundation avoiding dependencied on Standard/Enterprise APIs as well as build apps for SharePoint Standard+ versions. The further separation comes at the provision service level:

  • CSOMProvisionService
  • StandardCSOMProvisionService
  • SSOMProvisionService
  • StandardSSOMProvisionService

If the model has only SharePoint Fundation definitions - CSOMProvisionService/SSOMProvisionService can be used. If the model has SharePoint Standard+ definitions such as publishig pages, taxonomy, web mavigation settings - StandardCSOMProvisionService/StandardSSOMProvisionService should be used.

Solution

Mentioned exception "Cannot find model handler for type XXX. Current ModelService type: XXX" happens if the model has SharePoint Standard+ artifacts but XXXProvisionService is used. Simple use either StandardCSOMProvisionService or StandardSSOMProvisionService depending on your API.

Links

https://www.yammer.com/spmeta2feedback/#/Threads/show?threadId=588794087