Business Connectivity Services Write Back

One of the great new features of the Business Connectivity Services in SharePoint 2010 is the ability to write back to your data sources using user interface components that automatically configure and generate themselves for you. We’ll show you how to setup an External Content Type using BCS Meta Man, and a couple of options for how to write back within the SharePoint user interface.

  1. Open Visual Studio 2010
  2. Add a New Project
  3. Select ‘SharePoint’ > ‘Lightning Tools (2010)’ , now you can select the BCS Meta Man project type.
  4. Give your project a name i.e BCSMetaManDemo


    [Please click the images for a larger view]

  5. Click ‘OK’
  6. On the next dialog box, enter the name of where you want to deploy your model, and make sure you select ‘Deploy as a farm solution’ , click ‘Finish’

    Deploy as a Farm Solution 

  7. To show the ‘BCS Meta Man Data Source Explorer’ we need to enable it from the Menu item, this new window can be docked so it doesn’t get in your way. 

    BCS Meta Man Data Source Explorer 

  8. Click on the Add Connection button in the Data Source Explorer and connect to the data source you wish to use to create your External Content Type.

    Open the BCS Meta Man Data Explorer

  9. In this example we are going to use the AdventureWorks2000 sample database.
  10. With your database tables in view in the Data Source Explorer drag and drop one of them onto the BCS Meta Man design surface. Upon dropping the table a wizard will popup to help you configure the External Content Type.
  11. On the first step, choose to build a .Net Assembly model type – this means that BCS Meta Man will generate all the C# code for us, and the BCS Model to call the code.

    Select to create a .Net Assembly Connector

  12. The next step of the wizard allows you to setup the Identifiers for your External Content Type. If you want to be able to update external data through the BCS your External Content Type will need at least one identifier that can uniquely identify each row of data. If you have chosen a table that has a primary key setup for it, BCS Meta Man will figure out and select this column (or columns if it is a composite key) for you automatically. If your table does not have a primary key you’ll need to pick the column that can do this job for you. Once you are happy with the identifier selection, click Next

    Pick your Identifiers

  13. 8, The final step of the wizard is to pick the types of methods we want BCS Meta Man to initially generate for our External Content Type. The insert and update methods are not selected by default, so go ahead and click the checkboxes next to the Default Creator and Default Updater method and click on the Generate button.

    Make sure you have selected to generate the creator and updator methods 

    BCS Meta Man will now go and generate all the C# code and BCS Model your External Content Type needs to be able to display, insert and update the information in the external system.

  14. If you press F5 Visual Studio will compile and package the BCS Model and .Net Assembly Connector code and deploy it to SharePoint. It will also attach the debugger to the correct process so we can insert a breakpoint into our code somewhere and have Visual Studio step into it for us.


Create an External List

With our External Content Type deployed we can now create an External List to view and edit the data.

  1. While viewing your SharePoint site through the browser, click on Site Actions –> More Options…
  2. From the list of items to create select External List and click the Create button
  3. In the configuration screen that opens up, give your External List a name and use the External Content Type picker to select the External Content Type we have just deployed to SharePoint

    Use the External Content Type entity picker

  4. Click the Create button for SharePoint to create the External List and hook it up to use our External Content Type as a data source
  5. Upon clicking Create, SharePoint will create the External List for you and then navigate you to it.

    Viewing your new External List 

  6. You can hover over the first column of your list and you’ll see a drop down appear. If you click the drop down arrow you’ll get a number of options for that particular row of data – one of which will be Edit Item

    Edit items via the External List 

  7. This option is only available if you create an Updater method for your External Content Type. Clicking on this link will open up a dialog form that allows you to edit that row of data and save it.

    Edit item dialog 

    This will save the changes directly back to your external data system that the external content type is hooked up to.

  8. While viewing the external list, if you click the Items tab on the ribbon you’ll see a New Item button.

    Add new data through the external list 

    This button will only be active if your External Content Type has a creator type method. Upon clicking this button a dialog form will pop up and allow you to insert a new record.

Can you do this with the BCS Data List Web Part?

If you add a BCS Data List Web Part to your page and configure it to use the External Content Type we configured above you’ll notice that you do not get the New or Edit links available. Although you could configure the web part to have these it is a bit cumbersome, plus there is a much easier way!

16, Put your web part page into edit mode, and using the ribbon click to insert a new web part

17, From the web part picker select the External List you created from the List and Libraries section and click the Add button

Add your External List as a web part

18, Your external list will now render itself as a web part. You may need to edit the web part to switch it to a more friendly view, but once you do – you’ll see the Add Item and Edit links are rendered nicely for you…

Edit and add to your External System through the web part

Hope you have found this useful. If you have any questions about this walk through feel free to leave a comment or email


Leave a comment