This post is a continuation of the previous post. We have discussed that how to automate the Site Columns creation using Client Object Model. Now we will see that how to automate the Content Types creation.
1. Download and open the “SiteProvising” solution.
2. Once you create the site columns as I mentioned in part 1, we are ready to create the content type.
3. Right click the “Contoso.IntranetAssets” project and add the new folder “Content Types”.
4. Right click the “Content Types” folder and add the new item “Content Type” and name it as “Employee” and leave the base content type as “Item”.
5. Now select the site columns “Employee Name”, “Employee Age” and “Employee Address”.
6. Now run the “SiteProvisioning” project and select the option “Content Types”.
7. All the site columns will be created in the associated site collection.
Here is a source code for Content Type automation.
You can create the multiple content types under the folder “Content Types”. The above code will collect all the content types’ elements files and provision in the associated site collection.
I have detailed blog here why I choose this approach.