Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013

Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013

In this post, we will discuss how we can create a list definition and list instance in SharePoint 2013 using Visual Studio 2013. Here we will create a farm solution rather a sandboxed solution for this demo. Sandboxed solutions have been deprecated in SharePoint 2013, so we should avoid using Sandboxed solution in SharePoint 2013. But Sandboxed solutions will still work on SharePoint 2013. You can check an article on Differences Between Sandboxed and Farm Solutions in SharePoint 2013.


Unlike SharePoint 2010, SharePoint 2013 or SharePoint 2016 cannot be installed in a client operating system like Windows 8, 10 etc. So if you want to develop solutions using Visual Studio 2013, make sure you have Visual Studio installed on the same server where you have SharePoint 2013 installed. If you have started to learn SharePoint 2016, you can check SharePoint 2016 new features and SharePoint Server 2016 Installation Step by Step.

Also, you can see:
Create Visual WebPart using Visual Studio 2013 in SharePoint 2013

Delegate Controls in SharePoint 2013 using Visual Studio 2013

SharePoint 2013 Create a custom master page using Visual Studio 2013

Follow the below steps:
Open Visual Studio 2013 then File -> New -> Project. In the New Project dialog box, you will be able to see the lots of project templates. From the left side you can go to Installed -> Templates -> Visual C# -> Office/SharePoint -> SharePoint Solutions. Then in the right side choose SharePoint 2013 – Empty Project.

Then give a name for the project location where you want to Save and the name of the Solution and then click on OK. Here make sure you have selected .NET Framework version 4.5 is selected. Because .NET Framework 3.5 is not supported in SharePoint 2013. The dialog box will look like below:

Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013
Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013

Then in the next SharePoint Customization Wizard, give a local site URL for debugging. This site can be used for debugging and testing the project. This should be a local SharePoint site and should be available. Also, you can use the Validate button to validate the site. Then you have two option to select which type of solution you want to develop, here I have chosen a farm solution. But make sure you have SharePoint Administrator privileges to deploy the solution. It should look like below:

Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013
Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013

Once you will click on OK, Visual Studio will create the solution for you. There you will be able to see Features folder and Packages folder. Features folder will help in adding new features to a SharePoint project. Since we have created an Empty SharePoint project, so Feature folder is empty. Packages folder will help in building the solution package (.wsp) which can be used to deploy the solution to other servers apart from development servers like production or staging server.

Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2015
Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2015

Now we will add a list to the project. Right click on the Project -> Add -> New Item… This will open the Add New Item dialog box. From the Office/SharePoint templates select List from the available templates as shown in the fig below:

Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013
Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013

In the next dialog box, it will ask for list settings like, Give a name for your list. And choose whether you want to create a customizable list template or a list instance based on existing list type. Here I have chosen to use the Custom List template. It looks like below:

Create List Definition and List Instance in SharePoint 2016 using Visual Studio 2015
Create List Definition and List Instance in SharePoint 2016 using Visual Studio 2015

Once you add the list instance, a feature will also be automatically get created. The feature scope will be Web and the list instance will be added automatically to the feature. Now if you look at the solution explorer it will look like below:

Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013
Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013

Now let us do some customization to the design view of the list instance. There are 3 tabs in the design view: Columns, Views, and List.

In the Columns view, you will be able to see by default the Title column which comes in Custom list template. Here I have added another single line of text column to it which I named as the First Name. You can add a number of the column with different data types in it. If you want to make the column mandatory, just check the required checkbox which is presented in the last. It looks like below:

Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013
Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013

The next tab is the Views tab, by default, it will show All Items view. Here I have created on view name as My Test View and for this view, I have just added ID, Title, and First Name column and I have set row limit of 10. It will look like below figure.

Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013
Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013

The next tab is List tab where you can change the Title, List URL and Description of the list. Here also I have selected the check box “Display list at Quick Launch”, so that once the list got created it will appear in the Quick launch. It looks like below fig:

Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013
Create List Definition and List Instance in SharePoint 2013 using Visual Studio 2013

After this we will go and create two items for the list instance. Open the Elements.xml file which will looks like below

<?xml version=”1.0″ encoding=”utf-8″?>

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

<ListInstance Title=”MyCustomListDefinition” OnQuickLaunch=”TRUE” TemplateType=”100″ Url=”Lists/MyCustomListDefinition” Description=”My List Instance”>

</ListInstance>

</Elements>

Now we can add two items to the list like below:

<?xml version=”1.0″ encoding=”utf-8″?>

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

<ListInstance Title=”MyCustomListDefinition” OnQuickLaunch=”TRUE” TemplateType=”100″ Url=”Lists/MyCustomListDefinition” Description=”My List Instance”>

<Data>

<Rows>

<Row>

<Field Name=”Title”>Item-1</Field>

<Field Name=”FirstName”>Bijay</Field>

</Row>

<Row>

<Field Name=”Title”>Item-2</Field>

<Field Name=”FirstName”>Sahoo</Field>

</Row>

</Rows>

</Data>

</ListInstance>

</Elements>

Now our solution is ready for deployment. Since we are doing the development in development server, right click on the Solution, then click on Deploy Solution. It will do all the steps required for deployment.

sharepoint 2013 create list definition visual studio 2013
sharepoint 2013 create list definition visual studio 2013

If you want to deploy the solutions to other SharePoint servers where you will not have visual studio then you can see: How to deploy farm wsp solution in sharepoint 2010 using PowerShell?

Once the deployment is over, you can see your solution is deployed in the central administration. Open your SharePoint 2013 central administration, then click on System Settings. Then in the System Settings page, click on Manage farm solutions which are under the Farm Management section.

create list definition using visual studio 2013
create list definition using visual studio 2013

Here we have created web level feature, we can see the feature by going to Site Settings page Then from Site Actions section click on Manage site features link. We can see the feature already activated like below:

create list definition using visual studio 2013
create list definition using visual studio 2013

Also in the Site Content, we will be able to see the list got created with the name whatever we have given earlier. f you will open the list, we can see it has the extra columns (First Name) which we have added in the list definition, as well as the two items, are added which we have added. Apart from this, the view is also got created (My Test View) as shown in the fig below:

sharepoint 2013 create list definition visual studio 2013
sharepoint 2013 create list definition visual studio 2013

And the final thing we can check is the list definition should be available for us so that we can create another list by using the template. Click on the gear icon and then Add an App. You can search for the name you should be able to see the app. By using that template we can create lots of lists.

create list definition using visual studio 2015
create list definition using visual studio 2015


Hope this post will be helpful.

Check out Best Alternative to InfoPath -> Try Now

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →