Create SharePoint List Definition using Visual Studio (Step by Step Tutorial)

This SharePoint 2016 tutorial, we will discuss about SharePoint list definition, how to create SharePoint list definition using visual studio in SharePoint 2013, SharePoint 2016 or SharePoint 2019.

SharePoint List Definition

What is SharePoint list definition? A SharePoint list definition is like a template that we can use to create list and define the schema of a list in SharePoint. A list definition in SharePoint have all the information about the list, like columns, content types, list views etc. A list definition will have a feature.xml file, an elements.xml file and also a schema.xml file.

Difference between List Definition, List Template and List Instance in SharePoint

Let us see What is the difference between List Definition, List Template, and List Instance.

Before check the differences, we should know what is list definition, list template and list instance in SharePoint.

Difference between List Definition, List Template and List Instance in SharePoint

Here are a few differences between list definition, list template and list instance in SharePoint 2010/2013/2016 and SharePoint Online.

List definition in SharePoint

  • List definition defines the schema of a Sharepoint list. It contains all the metadata information as well as what are the content types, columns used. This also contains about information what views are being used.
  • We can create a SharePoint list definition using Visual Studio only.

List Template in SharePoint

  • List template is a template through which you can create a list instance. You can create a list template by using the SharePoint browser or SharePoint designer.
  • It contains list columns, site columns, content types, views etc.

List Instance in SharePoint

  • A List Instance is a single “instance” of a list created from an aforementioned list definition. A List instance can also be instantiated with data.
  • A list instance is an instance of a specific SharePoint list definition or list template. All of its data is stored in the relevant content database. Typically a list in SharePoint used by end users to enter and view data and it is based on either a list template or list definition.

Create Custom List Definition in SharePoint

Now, let us see step by step how to create a custom list definition in SharePoint 2016/2013 using Visual Studio.

After you install visual studio 2015/2017/2019, you might not see all the SharePoint project templated like SharePoint 2016 empty project, SharePoint 2016 – visual web part, etc. In that case, you need to install Microsoft Office Developer Tools Preview for Visual Studio 2015 (For visual studio 2015).

Then Open your visual studio and then click on File -> New Project and then from the left side expand Installed -> Templates -> Visual C# -> Office/SharePoint. From the right side click on SharePoint 2016 – Empty Project like below:

sharepoint 2016 create list instance using visual studio
sharepoint list definition

Next, in the SharePoint customization wizard choose a local site for debugging, and you can optionally validate which will validate the site. And then choose to Deploy as a farm solution like below:

create list definition and list instance in sharepoint
sharepoint 2013 list definition

Then it will make your empty solution ready like below:

create list definition and list instance in sharepoint 2013
sharepoint list definition

Then we will add a list to the project.

Right-click on the project -> Add -> New Item. In the Add New Item dialog box choose List from the list of installed templates like below:

create list definition and list instance in sharepoint 2016
sharepoint 2016 list definition

Then in the next step give a name for the list and choose “create a customizable list template and a list instance of it” and choose Custom List template like below. Since we are creating the list using a custom list template by default it will create one column name as Title.

how to create a custom list definition in sharepoint 2016

Then we will add here two more single lines of text columns like Email ID and Contact Number. Then we will add a Choice column like Course.

To add values to the Choice column, from the properties window expand Type and then click on Items… like below:

create list definition and list instance in sharepoint using visual studio
Create custom list definition in SharePoint

This will open the String Collection Editor where we can add the choice options one per line like below:

create list definition and list instance in sharepoint 2013

Then we will add multiple lines of text like below and then to enable Rich text mode to select RichTextMode as full HTML like below:

create list definition and list instance in sharepoint 2016
custom list definition

After this all your columns will look like below:

How to create a custom SharePoint list definition using Visual studio

Then we will create a new view. Go to the Views tab and then give a name for the View and then choose the columns which you want to add to the Column like below, in these particular examples we are going to add the columns which we have created here.

sharepoint create list instance programmatically

By going to the List properties we can change the properties of the list like Title, List URL, Description and optionally you can check the checkbox to display list at quick launch and Hide list from a browser like below:

sharepoint 2016 create list instance programmatically

Now it is time to deploy the solution Right-click on the solution -> Deploy solution as shown in the fig below:

sharepoint 2013 create list instance programmatically
sharepoint list definition

Once it deployed successfully, you can see the list got created in SharePoint 2016 site. Go to the SharePoint site, site content page, you can see the list got created.

You may like following SharePoint Visual Studio tutorials:

In this SharePoint tutorial, we learned about SharePoint list definition, how to create a list definition and list instance in SharePoint 2016 using visual studio 2015/2017/2019.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>