Danushka Silva

It's all about SharePoint

How to: Create an External Content type using SharePoint Designer 2010 (Business Connectivity Services)

Here we are going to do a lab that creates an external content type using SharePoint 2010. Assume your company has a database with product details. You need to retrieve those details from the database and show them in the SharePoint site. Here you need to create, update and delete those records within SharePoint environment. So basically we are talking about creating CRUD methods for the external database inside the SharePoint UI.

First I will breakdown entire process into few points where we can very easily follow.

  • Create an External Content Type in SharePoint Designer 2010.
  • Create CRUD methods.
  • Deploy the external content type to SharePoint server.
  • Create an external list
  • Test the lab

OK… will start SharePoint designer and connect to our site. Once you connected to the server you get all the site objects on your left pane. Select External Content Types and you get all the external content types listed on the right pane.

BDCInfo1

Create new external content type by clicking External Content Type button on the top left corner

BDCInfo3

It will open the new external content type screen. Here you can change the key information of your external content type such as Name, Display Name , etc.

BDCInfo41

Now we have to create the data source to connect to our external database. Go to the bottom of the screen and click ‘Click here to discover external data sources and define operations’ link.

BDCInfo42

Now you’re in the screen where you can manage connections to external data sources and operations for the external content type you are going to create.

BDCInfo5

Click Add Connection to add our data source and select SQL Server from the dropdown menu. Press OK button

BDCInfo6

Type your Database Server and Database Name. Select the appropriate security method to connect and press OK.

BDCInfo7

Here you can see your data source has been added to the list.

BDCInfo8

Now we need to add methods to perform our CRUD actions. So will select the Product table which we need to extract data from and right click. Here you can see all the operations you can add to the particular table. Select New Read List Operation from the menu.

BDCInfo9

Now you can see the pop up window where you can configure read list operation. Change the names as you want and click Next.

BDCInfo10

Next you can add filter parameters to filter your data. Otherwise it will make large result with unwanted data. Since our lab database doesn't have much data, we skip that part. Press Next.

BDCInfo11

Here you can see all you columns in the table and select the appropriate columns to show in the external list. You can change their Display Names as well. Make sure to select Map to Identifier check box in the primary key. Click Finish

BDCInfo12

Now you can see the Read List operation in the External Content Type Operations.

BDCInfo13

Create the read item operation the way we did to read list operation.

BDCInfo14 BDCInfo15

 BDCInfo16

Create operation.

BDCInfo17

I have removed Product ID column from create because it’s an auto number field.

BDCInfo18 BDCInfo19

Update operation.

BDCInfo20 BDCInfo21

Delete operation.

BDCInfo22 BDCInfo23

Now we have created all the methods we want and you can see that in the External Content Type Operations

BDCInfo24

Now save the SharePoint Designer and it will automatically deploy the external content type into SharePoint server. If you go to the central administration site you can see the external content type has been deployed. Application ManagementManage Service ApplicationsBusiness Connectivity Services.

BDCInfo25

Now we go to the site and create an external list. Go to Site ActionsView All Site Content

BDCInfo26

Click Create button on top of the page.

BDCInfo27

Select External List and click Create button on the right.

BDCInfo28

It will open the external list creation page. Type the name and select the external content type from the dialog and click Create

BDCInfo29

Lets see how it will look like.

BDCInfo43

This is how item view looks like

BDCInfo30

Just check the create, update and delete operations. smile_wink