How to Create Lists in SharePoint Using Visual Studio 2015

(Step-by-Step Tutorial)

At Imaginet, we’re always looking for better and faster ways to accomplish technology goals.  In this article, we’ll explore how to create lists in SharePoint using Visual Studio 2015 in a few simple steps, making your list creation more efficient than ever.

Before we being, be sure your development environment meets the requirements for developing SharePoint solutions. You can check those requirements for each edition of Visual Studio here.

 

STEP 1: Create the Solution

The first thing we want to do is make sure you run Visual Studio 2015 as an administrator. This will allow you to debug your code without running into permissions issues.

Create Lists with SharePoint Using Visual Studio 2015: How to Creating Lists in SharePoint Using Visual Studio 2015 (Step-by-Step Tutorial) - The first thing we want to do is make sure you run Visual Studio 2015 as an administrator. This will allow you to debug your code without running into permissions issues.

 

EXPERT TIP: You can also set your Visual Studio shortcut to run as administrator automatically by configuring it in the Advanced Properties of the shortcut. You can get to this by right clicking the icon and clicking properties.
Create Lists with SharePoint Using Visual Studio 2015: EXPERT TIP: You can also set your Visual Studio shortcut to run as administrator automatically by configuring it in the Advanced Properties of the shortcut. You can get to this by right clicking the icon and clicking properties.

 

With Visual Studio open, let’s now create a SharePoint Project by going through the File -> New -> Project menu.

 

Create Lists with SharePoint Using Visual Studio 2015: With Visual Studio open, let’s now create a SharePoint Project by going through the File -> New -> Project menu.

 

Select SharePoint 2013 – Empty Project, and give your project a name.

 

Create Lists with SharePoint Using Visual Studio 2015: Select SharePoint 2013 – Empty Project, and give your project a name.

 

Enter the URL of your local SharePoint development site. You will also get to choose between deploying as a farm solution or a sandboxed solution, but for our tutorial, we will choose Deploy as a sandboxed solution.

 

Create Lists with SharePoint Using Visual Studio 2015: Enter the URL of your local SharePoint development site. You will also get to choose between deploying as a farm solution or a sandboxed solution, but for our tutorial, we will choose Deploy as a sandboxed solution.

 

STEP 2: Organize your Items with Solution Explorer

Now that our solution has been created, we can view what Visual Studio has created for us in the Solution Explorer. It’s good practice to add folders for the columns, content types, and lists so everything is organized. You can do this by right clicking on the project and choosing Add and then New Item.

Create Lists with SharePoint Using Visual Studio 2015: Now that our solution has been created, we can view what Visual Studio has created for us in the Solution Explorer. It’s good practice to add folders for the columns, content types, and lists so everything is organized. You can do this by right clicking on the project and choosing Add and then New Item.

 

STEP 3: Add Site Columns

Now let’s right click on our newly created Columns folder and add some site columns to it. We’ll add all future items to the project the same way we added the folders. Right click on the Columns folder and add a Site Column.

 

EXPERT TIP: You should enter your column names without a space. Visual Studio will automatically add a space within the column name.

 

Create Lists with SharePoint Using Visual Studio 2015: Now let’s right click on our newly created Columns folder and add some site columns to it. We’ll add all future items to the project the same way we added the folders. Right click on the Columns folder and add a Site Column.

 

Once you create a column, you’ll notice that Visual Studio has automatically added a Feature to the project and included the new column in it.

As we’re adding columns, we will need to update a couple fields to fit our solution, such as the Group and Type. Below are two different columns: a text field and a choice field:

 

Create Lists with SharePoint Using Visual Studio 2015: Text Field: Once you create a column, you’ll notice that Visual Studio has automatically added a Feature to the project and included the new column in it. As we’re adding columns, we will need to update a couple fields to fit our solution, such as the Group and Type. Below are two different columns: a text field and a choice field.

Text Field

Create Lists with SharePoint Using Visual Studio 2015: Choice Field: Once you create a column, you’ll notice that Visual Studio has automatically added a Feature to the project and included the new column in it. As we’re adding columns, we will need to update a couple fields to fit our solution, such as the Group and Type. Below are two different columns: a text field and a choice field.

Choice Field

 

EXPERT TIP: Here are links to MSDN documentation on the different types of columns you can create and another link on the definitions for those columns.

 

STEP 4: Add a Content Type and Columns

Now let’s create some content types to hold the columns. Not every solution requires content types, but we’ll still explain how to configure one in the event your project requires them. Right click on the Content Type folder, and select Add a New Item. This time select Content Type, and give it a name.

Create Lists with SharePoint Using Visual Studio 2015: Now let’s create some content types to hold the columns. Not every solution requires content types, but we’ll still explain how to configure one in the event your project requires them. Right click on the Content Type folder, and select Add a New Item. This time select Content Type, and give it a name.

 

You’ll be prompted to select the parent content type from which to inherit. In our case, we’ll choose Item.

 

Create Lists with SharePoint Using Visual Studio 2015: You’ll be prompted to select the parent content type from which to inherit. In our case, we’ll choose Item.

 

Once the content type has been created, we’ll now have a chance to add the site columns we created previously. Click on the first line in the content type, and enter the Display Name of the column. Visual Studio will populate a list of possible columns once you start typing.

 

Create Lists with SharePoint Using Visual Studio 2015: Once the content type has been created, we’ll now have a chance to add the site columns we created previously. Click on the first line in the content type, and enter the Display Name of the column. Visual Studio will populate a list of possible columns once you start typing.

 

STEP 5: Add a List with Content Types

Now we can finally create the list itself. Right click on the List folder, and click on Add -> New Item -> List and enter a name for the list.

Next, we’ll decide on the list type which will either be a new instance (list/document library/announcement/etc) or a list that will inherit from an existing one. For our scenario, we’ll create a new instance of a default list.

 

Create Lists with SharePoint Using Visual Studio 2015: Now we can finally create the list itself. Right click on the List folder, and click on Add -> New Item -> List and enter a name for the list. Next, we’ll decide on the list type which will either be a new instance (list/document library/announcement/etc) or a list that will inherit from an existing one. For our scenario, we’ll create a new instance of a default list.

 

Next, we’ll add the content types to the list. If we didn’t need content types, we could directly type the columns into the list, but for our scenario, we’ll click on the Content Type button towards the bottom of the list.

This will open the Content Type Settings. Here we’ll type in the content type names, and again, Visual Studio will begin populating available content types from which to choose.

 

Create Lists with SharePoint Using Visual Studio 2015: Next, we’ll add the content types to the list. If we didn’t need content types, we could directly type the columns into the list, but for our scenario, we’ll click on the Content Type button towards the bottom of the list. This will open the Content Type Settings. Here we’ll type in the content type names, and again, Visual Studio will begin populating available content types from which to choose.

 

Once you choose a content type, the list will be populated by the columns in the order you entered them for that content type. If you choose multiple content types, then the list will show all of the columns in the list grid shown below:

 

Create Lists with SharePoint Using Visual Studio 2015: Once you choose a content type, the list will be populated by the columns in the order you entered them for that content type. If you choose multiple content types, then the list will show all of the columns in the list grid shown below:

 

Your resulting solution should look something similar to the screenshot below:

 

Create Lists with SharePoint Using Visual Studio 2015: Your resulting solution should look something similar to the screenshot below:

 

STEP 6: Deploy and View your List

Lastly, after we’ve populated our list, we can deploy it to our site. Remember, every default deployment from Visual Studio will delete the existing list and list definitions. Extensive documentation on SharePoint solutions can be found here.

Right click on your solution in Visual Studio, and select Deploy. Now open your site, and view your list!

 

Create Lists with SharePoint Using Visual Studio 2015: Lastly, after we’ve populated our list, we can deploy it to our site. Remember, every default deployment from Visual Studio will delete the existing list and list definitions. Extensive documentation on SharePoint solutions can be found here. Right click on your solution in Visual Studio, and select Deploy. Now open your site, and view your list!

 

Unsure if you could do this yourself?

Imaginet’s SharePoint experts are always here to help. For over 18 years, our team of certified professionals can conquer any of the your SharePoint needs, from handling daily SharePoint tasks (like SharePoint list creation) through our SharePoint Managed Services program to full-on SharePoint deployments, upgrades, migration, and custom SharePoint solutions.  Contact us at info@imaginet.com or 1-800-989-6022 for more information.

 

Imaginet is your trusted technology partner who turns your business innovation ideas into reality. 20+ years | 1200+ satisfied customers | 2500+ successful engagements. Located in Dallas (Irving), Winnipeg, Calgary, and St. Louis. Services offered worldwide. Contact us today at info@imaginet.com or 1-800-989-6022.

 

Imaginet

About Imaginet

Imaginet is your trusted technology partner who turns your business innovation ideas into reality. 20+ years | 1200+ satisfied customers | 2500+ successful engagements. Located in the United States (Dallas, TX) and Canada (Winnipeg, MB). Services offered worldwide. Contact us today at info@imaginet.com or 1-800-989-6022.

9 Comments

  • Hi Sonny, Thank you for creating step by step guide to create lists in sharepoint. I’m bit confused to know is it working with VS 2010?

    I didn’t upgrade my VS because of client project so just curious to know your view point.

    Cheers, Ashutosh

    • Sonny Thai says:

      Hi Ashutosh,

      Yes, the process is the same for Visual Studio 2010. Feel free to ask here or shoot me an email if you have any questions!

  • Roselle says:

    Thanks for sharing this step by step guide. We were able to create a custom list definition for our site with views and attached custom forms. But recently we bumped into an issue that the library created using the custom list definition does not display any file/folder when opening using any of the MS office products. We hope you could help us.

    Keep sharing, Roselle 🙂

  • Joan Martin says:

    Hello,

    Thanks for Sharing this amazing post about Create List in SharePoint. Glad to see your other blog about SharePoint.

  • Espo says:

    Thanks for the detailed instructions.

    How can I add content to the list using VS. It appears the tag is not longer supported in the List instance XML

    Announcement 1
    Announcement 1 Body 1

    • Imaginet says:

      Glad you found these instructions helpful.
      In response to your question, you would need to develop a custom List Event receiver to programmatically add content to the list. However, we would recommend other, more modern applications for updating content, such as bulk insert through Quick Edit or the out of the box UI. If you have additional questions or need assistance, feel free to contact us at info@imaginet.com

  • Don Fisher says:

    Is there a way to accomplish this without installing SharePoint Server or SharePoint Foundation on my local machine? When I go to create the solution, I get an error stating ‘The required version of SP Foundation or SP SERver is not installed on this system.’.

  • ami says:

    Hi
    A very good article.Like a user guide 🙂 Thank you.

    May I know how i can use the title column in th econtent type? I dont want a separate title column in my list instead I want to use only columns I defined in my content type. I know the Title column in part of item content type.How we usually use this column in such scenario ? can you please guide?

    ami

Leave a Reply