SPC’09: Building Solutions with Business Connectivity Services using Visual Studio 2010

Disclaimer: This post is based on notes taken while watching a conference session. For that reason, it may contain incorrect information or data that I might have misunderstood. Also, the product it refers to was not available yet at the time of the writing, thus, not allowing me to validate the present information.

This was the second session I attended on the second day of the SharePoint Conference 2009 and it was given by Rolando Jimenez from Microsoft.

Business Connectivity Services

According to Rolando, Business Connectivity Services (BCS) are “a set of out-of-the-box features, services and tools that enhance SharePoint to streamline solutions of deep integration of external data and services.”

In the SharePoint Pie, Business Connectivity Services belongs to the Composite slice. It’s the new and much improved version of the old Business Data Catalog, introduced in SharePoint 2007.

Regarding BCS, Microsoft has invested in three main areas:

  • Presentation: extend Office and SharePoint’s user experience and capabilities to external data and processes.
  • Connectivity: read-write capable connectivity from client and server to databases, WCF/Web Services and .NET sources.
  • Tooling: integrated tooling experience scales from simple solutions to advanced applications with rich client packaging and deployment.

Core Concepts

The main building block for BCS is the new concept of External Content Type (ECT), which is the new name for what was previously known as BDC Entity. An ECT describes:

  • How to connect to the data
  • Schema of the data
  • Behavior within Office and SharePoint

This definition will then be used by the BCS Runtime, both in SharePoint (thin client) and in Office Client applications (rich client) to access the external data.

The other important concept is the External List. This is a new type of list in SharePoint 2010 that allows you to surface data retrieved by BCS as defined by the External Content Type associated to it.

BCS Tools Overview

There are three types of solutions that use BCS:

  • Simple No Code solutions, which can be built by Power Users using SharePoint Designer
    • Surface data in SharePoint using External Lists
    • Connect those lists to Outlook and SharePoint Workspace and take them offline
  • Intermediate No Code solutions, which can be built by developers using SharePoint SDK (and eventually also SharePoint Designer)
    • Customized InfoPath forms
    • Customized Office Ribbon and TaskPanes
    • Customized QuickParts in Word
    • Customized Workflows
    • Customized Web Part Pages
  • Advanced Solutions, built by Advanced Developers using Visual Studio (and SharePoint SDK and SharePoint Designer).
    • Custom connectivity for data aggregation, transformation, security, …
    • Using custom code to integrate data into any Office application (even the ones that don’t support BCS directly)
    • Business logic in forms
    • Create reusable components (UI parts, ECTs, actions) to be included in simpler solutions

Regarding solution creation, there are mainly two approaches:

  • Client-Server Environment – PowerUsers use a live connection to the server and directly build simple no code solutions on the server or rich client.
  • Single Machine Development Environment – Developers use a combination of SharePoint Designer, SharePoint SDK and Visual Studio to produce advanced solutions, packaged in WSP files that can then be deployed to any SharePoint farm.

Demos

After the overviews, Rolando demonstrated a few Advanced Solution scenarios. Here are the notes I gathered from the demos.

Demo 1: BCS Hello World

  • There is a new project type in Visual Studio 2010 called Business Data Connectivity Model Project which can contain a collection of ECTs
  • The graphical designer makes it very easy to build ECTs
  • An ECT is a class with at least:
    • One property called ID
    • A method called ReadList
    • A method called ReadItem
  • Visual Studio 2010 includes a BCS Explorer tool which graphically shows the structure of the XML-behind generated when designing the ECTs
  • Visual Studio 2010 can package and deploy the ECT directly to SharePoint

Demo 2: Author Custom Connectivity in Visual Studio

  • If you want to retrieve data from multiple tables and aggregate it in a single ECTs you have to develop the code yourself (for each ECT class method).
  • If you want to allow writes on ECTs, you must add an Update method to the ECT class.
  • SharePoint automatically generates and Edit Form for External Lists that support writes.

Demo 3: Discover and Configure ECT for Outlook Offlining in SharePoint Designer

  • Using SharePoint Designer you can define a mapping between ECT properties and Outlook objects, allowing you to connect an external list to Outlook (really neat stuff).
  • When packaging the solution, Visual Studio will generate a WSP for SharePoint deployment and a Click-Once package for Office Client deployment (similar to Office Add-Ins).
  • The same code (ECT assembly) is executed by the BCS Runtime on the Office Client and on SharePoint.

Demo 4: Custom Rich Client Integration (Excel) with VSTO

  • Using the BCS API, a developer can built an Excel Add-In, using VSTO, that loads the data using the ECT and inserts into a spreadsheet.
  • The developer can specify if it allows BCS to cache the data or if the data always has to be live.