Implementing BCS Solutions using Stored Procedures

Recently I had a client request a BCS solution to provide custom forms to enable customers to manage their profiles and allow employees and other customers to be able to view those profiles. They wanted a BCS solution instead of a traditional web application with a database backend in order to take advantage of SharePoint Enterprise Search. This approach would allow users to be able to search against any customer information that is stored in SQL Server. In addition, they wanted a SharePoint solution package so that they can deploy/redeploy to multiple environments (Integration, QA, and Production).

Customer’s profile information was in tables but not in a form that was directly meaningful to end users (for example they have different types of contact information as different records in the same table and used as lookups). In addition, some of this data was imported from other systems by timer jobs and triggers. The solution was to abstract the data for the BCS by using stored procedures. So our challenge was to develop a BCS solution package(s) based SQL Server stored procedures.

Sounds reasonable…

If you have read any of the marketing materials on the BCS, you would think that the BCS is most ideal way to achieve the client’s goals. SharePoint articles and books would then state that you can create External Content Types (ECTs) and External lists in SharePoint Designer (SPD) and you can be done in an hour or two. To access this data, you can create web parts that use the SharePoint API to access the External lists just like any other SharePoint list.

Easy, right? Well, let’s explore some of the issues that are common to all BCS Solutions and then take a further look at the issues that this particular approach brings up.  For each issue, I will explain our design decisions and the final solution.

Issue 1: Authenticating a BCS Solution to an External System

Issue 2: Defining and developing your BCS entities into ECTs

Issue 3: BDC Models, Resource files, and making Content Types Searchable

Issue 4: How to develop and deploy the ECTs/BDC Models to multiple environments

Issue 5: Implementing ECTs in SPD using Stored Procedures

Why choose a BCS solution?

Surfacing external data in SharePoint enables users to build composite applications that give access to critical information and make their interactions with that information more convenient.  Business Connectivity Services (BCS) is the SharePoint service which allows surfacing of external data from SQL Server, Web Services, or.NET Assembly Connector.  SharePoint even provides no-code BCS solutions to surface the external data via SharePoint Designer to allow for rapid development and provides External Lists to quickly interacting with that data.  You can also secure the data by setting permissions on who can create, read, update, and delete (CRUD) the data.  You can even crawl that data using SharePoint Enterprise Search and set a profile page for rendering the search results in a meaningful way.  You can rapidly developing a feature rich front end for your external data.

Search enabling your BCS solution will however require more than SharePoint Designer to develop.  This is also true if you want to deploy your solution to multiple environments.  This does not mean that you have to write code, but it does mean that you will find yourself in Visual Studio modifying declarative markup that SharePoint Designer can produce and packaging that markup into WSP solution packages.  This approach will allow you to develop external data solutions that you can quickly develop and deploy to multiple environments consistently and will provide your users the ability to immediately search and render meaningful results.

Now if you do determine that you need to integrate external data with SharePoint, but want to still have custom forms or any kind of richer user experience to interact with that data, you could write code using the SharePoint API against external lists.  This approach is often touted as one of the great things about external lists in that you can treat them as any other SharePoint lists.  This approach will work for small datasets, but for large datasets and anytime you are concerned about performance of your forms, you will really want to write your code to go against the BCS Runtime or Client Object Models.  This is a very powerful approach as you can now develop a very rich custom user interface to interact with your external data within the SharePoint context.  You can even access your external data from other applications via the BCS Client Object Model.

As I have discussed, SharePoint provides for rapid development of external data and allows you to apply security and search on your external data.  It also provides the capability to build very powerful and very rich custom user experiences for your external data.  Implementing these solutions to different environments and making your application production ready presents some challenges that are not well documented.  In my next few blog posts, I will go through the process of making an external data solution from beginning to end and show you techniques that will make your solution more stable and production ready.