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.
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 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 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.
- 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.
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:
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:
Then it will make your empty solution ready like below:
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:
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.
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:
This will open the String Collection Editor where we can add the choice options one per line like below:
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:
After this all your columns will look like below:
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.
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:
Now it is time to deploy the solution Right-click on the solution -> Deploy solution as shown in the fig below:
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:
- SharePoint Hosted Add-in: Send Email to SharePoint group using visual studio workflow
- Create a Web API for SharePoint Online
- Develop SharePoint workflows using visual studio as SharePoint hosted App
- Create a custom action group in SharePoint 2013/2016 using visual studio
- SharePoint 2016 Develop and deploy custom feature using Visual Studio 2015
- Create a web part page using the visual studio in SharePoint 2013
- Create and deploy site pages or content pages using the visual studio in SharePoint 2013/2016
- Create a custom master page using Visual Studio in SharePoint 2016/2013
- Create an application page in SharePoint 2013 using Visual Studio
- Create custom delegate control in SharePoint 2013/2016 using Visual Studio
- Customize list view using jslink SharePoint Online
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.
Bhawana Rathore is a Microsoft MVP (3 times in Office Apps & Services) and a passionate SharePoint Consultant, having around 10 years of IT experience in the industry, as well as in .Net technologies. She likes to share her technical expertise in EnjoySharePoint.com and SPGuides.com