Site Column project item template in Visual Studio 2012


In Visual Studio 2010 we need to use Empty Element template to create the site columns whereas Visual Studio 2012 introduced a new project item template called Site Column for SharePoint 2013. By using this template it is easy for the SharePoint developers to create a site column by doing some minor changes.

Steps Involved:

1.       Open Visual Studio 2012 (Run as administrator).

2.       Go to File=> New => Project.

3.       Expand Visual C# node, then expand Office/SharePoint node in the templates panel.

4.       Select SharePoint Solution, click on SharePoint 2013 Project.

5.       Enter the Name and then click on Ok.

6.       In the Solution Explorer right click on the solution and then click on Add.

7.       Click on New Item.

8.       Select Site Column item template from the installed templates and enter the name for the site column.

9.       Click on Ok.

10.   By default the following field attributes will be available in Elements.xml if you want to update do the changes and deploy.

 

<?xml version="1.0" encoding="utf-8"?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> 

  <Field

       ID="{0836b05c-375a-466f-977d-0ddd2659ea0b}"

       Name="SiteColumn1"

       DisplayName="Site Column 1"

       Type="Text"

       Required="FALSE"

       Group="Custom Site Columns">

  </Field>

</Elements>


11.   Site Column will be created successfully.