Creating custom content type using an object model
In the previous recipe, we extended a content type using an XML schema. This can get pretty difficult as Visual Studio does not provide ways to debug the XML schemas. Instead of using the xml schema method, you can always use object model APIs to create the content type. In this recipe we will do just that.
For this recipe, we will create a new content type called Project Proposal that has four custom columns Amount, Department, Project Start Date, and Project End Date. The Department
field is a choice type where you can select the department to which the project belongs. The Amount
field is of currency type and the Project Start Date
and the Project End Date
are of DateTime
type. The content type will be inherited from the document content type.
Getting ready
You should have completed the previous recipes successfully.
How to do it...
Launch your Visual Studio 2010 IDE as an administrator (right-click the shortcut and select Run as administrator...