Walkthrough of creating a SharePoint 2010 external list using Visual Studio 2010

Walkthrough of creating a SharePoint 2010 external list using Visual Studio 2010

  • Comments 6

There are a bunch of SharePoint features in Visual Studio 2010. You may have already heard about them from reading the blog Short Overview of SharePoint Features in Visual Studio 2010 or by other means. Today I want to introduce one of them, Business Data Connectivity (BDC) designer, which is available in the project template Business Data Connectivity Model. If BDC is new to you, here is a short description. BDC is one of two most important architectural components of Microsoft Business Connectivity Services (BCS) which enables users to read and write data from external systems—through Web and Windows Communication Foundation (WCF) services, databases, and Microsoft .NET Framework assemblies—from within Microsoft SharePoint 2010 and Microsoft Office 2010 applications. This MSDN webpage Business Data Connectivity (BDC) Service has a more descriptive version.

Visual Studio 2010 helps a SharePoint developer to develop, debug and deploy .NET assemblies as external data sources to SharePoint. In the following paragraphs, I will walkthrough with you how to create your first SharePoint external list using Visual Studio 2010. In order to make this walkthrough work on your machine, you need to install SharePoint 2010* and Visual Studio 2010#.

*: Please read Setting Up the Development Environment for SharePoint Server before the installation. If you are using SharePoint Foundation 2010 you will need to create a Feature Event Receiver to enable the import of BDC models. How to create a Feature Event Receiver will be covered in a future blog post.

#: Please make sure Microsoft SharePoint Development Tools component is selected when installing. It is chosen by default if you choose Full installation.

Let’s start the journey.

1. Create a new BDC Model project. (Main menu: File -> New -> Project…). In the left column of the New Project dialog, you are able to find node 2010 under tree view Visual C# -> SharePoint. Similarly you can find same node under Visual Basic -> SharePoint. In the middle column of the dialog, you should be able to see Business Data Connectivity Model listed as one of the project templates. See the screenshot as follows. Here I am creating BDC Model project in Visual C#. You are able to do the same things in Visual Basic.

2. After clicking [OK] button in the New Project dialog, the SharePoint Customization Wizard dialog will be displayed. In this dialog you can customize the local site you want to target and trust level for the SharePoint solution. Since a BDC model is deployed to a farm, a collection of one or more SharePoint servers and one or more SQL servers, only “Deploy as a farm solution” option is enabled. Here is the screenshot of the dialog.

3. When you click [Finish] button in the SharePoint Customization Wizard dialog, the BDC Model project will be created. There are four main UI panes that help you manage the BDC model visually. They are the BDC Designer Surface, BDC Method Details Pane, BDC Explorer, and Properties Browser.

a. The BDC Designer Surface allows editing entities, identifiers, methods, and associations between entities. And you can do that either from toolbox or context menus.

b. The BDC Method Details pane, where its name is already self-explanatory, lets you edit everything related to a method, from the method itself, its parameters to its parameters’ type descriptors, from method instances to filter descriptors, etc.

c. BDC Explorer lists and organizes metadata objects in the BDC model in a tree view. It lets you to browse and search metadata objects in a graphical way and allows you to copy/cut/paste type descriptors between different parameters or type descriptors.

d. Properties Browser gives you a familiar way of editing components and attributes of BDC Models. We use it to supplement the functions offered by the other three panes and list all the attributes for a particular metadata object for editing. Here is a typical layout of a BDC Model project as described above.

4. If you notice, there is already a default entity generated for you when the project is created. This default entity also has an identifier and two methods ReadItem and ReadList created. One is a Finder method that is to return a collection of data. The other is a Specific Finder method that is to return a specific entry based on the input parameter(s).

5. Now let’s deploy to the SharePoint server. You can either click the deploy menu item in main menu (Build -> Deploy Solution), or in the context menu of the project or the solution. In the output you will see several activities happening including packaging, solution retraction/addition, deployment, etc.

6. Let’s open the target site and see if our model has been successfully deployed. Open the target site with any browser supported by SharePoint, like Internet Explorer 8. Create an external list based on the model we just deployed. Here are the steps to create an external list in case you are new to it.

a. In main menu: Click Site Actions -> More Options…

b. On the Create dialog, select External List, click [Create] button in the right column

c. On the next external list create form, type a name for the list. Check ‘Yes’ to display the list on the Quick Launch for easy access. Then click to select the model we just deployed in the External Content Type Picker form. Click [Create] on the external list create form. Now the Hello World list is displayed.

 

In the main menu under List Tools -> Items, you may find only “View Item” option is enabled. Guess why? Yes, it is because the default entity only has a Finder method to view the entire list and a Specific Finder method to view a specific item. In our next blog in this series, we will show you how to add more functions like Add, Update and Delete to the list as well as pull data from external data sources.

Jeff Chen

Leave a Comment
  • Please add 5 and 2 and type the answer here:
  • Post
  • The title of this post is misleading. You're not creating an external list in Visual Studio. You're creating an external list through the SharePoint UI. I was hoping to find a post on how I can use the "list instance" template in Visual Studio 2010 to provision an external list. Is that even possible?

  • Thanks for the comments, Matt. The purpose of this post is to tell people how to use BDC feature within VS2010. External list is just a place to show the result. Of course, we can create a list instance in VS2010 and connect to external data through BDC. We will consider it one of our future blogs. If you are just looking for how to use list instance in VS2010, there are a couple of online documents talking about that already, e.g. http://msdn.microsoft.com/en-us/library/ee231593.aspx.

  • Some how I am not able to see the External list option on create page. I am seeing only very few... Why?

  • Hi Praveen,

    Do you see options to create other lists such as custom list? Could you tell us what options do you see currently? It'll be helpful if you can send us a screenshot.

    Rong

    Program Manager, Visual Studio team

    (ronglu at microsoft dot com)

  • I agree with Matt. The title is misleading.

    How do you create and customise the edit/view form of the external list via VS2010.

    I know how to do this in InfoPath 2010 and SPD 2010, but how to do this in VS2010 ?

    Is there any post or tutorial that I can follow ?

  • Great article,for anyone's who is interested there's a similar article using SharePoint designer instead over at <a href='www.typeerror.com/.../&

Page 1 of 1 (6 items)