Deploy a BDC Model project to SharePoint Foundation 2010 using Visual Studio 2010

Business Connectivity Services (BCS), one of the key components of SharePoint 2010, helps you to access external line-of-business (LOB) data. The SharePoint team posted a blog entry which demonstrates how to create your first BDC (Business Data Connectivity) model using Visual Studio 2010. As indicated in the post, you can use Visual Studio 2010 to deploy your BDC model to Microsoft SharePoint Server 2010.

However, if you are using Microsoft SharePoint Foundation 2010 on yourdevelop machine, or you want to make the model deployable to Microsoft SharePoint Foundation 2010 on other machines , you will need to write a Feature Event Receiver to enable the deployment of BDC models from within Visual Studio 2010. In this blog post, I’ll show you how to create a Feature Event Receiver to do so.

Here are the detailed steps:

  1. In Visual Studio 2010, create a BDC project (read this post to learn how) or open your existing BDC project (e.g. “BdcModelProject1” ) .

  2. Add Feature Event Receiver to BDC project. In Solution Explorer, add a new Feature Event Receiver by right clicking on the feature (Feature1 in this sample) under Features folder and selecting Add Event Receiver.

  3. Write code for the Feature Event Receiver. In the generated code file (the default name is Feature1EventReceiver.cs/vb), replace the code with the sample code (Download here).

  4. Add reference.

    1. Copy Microsoft.BusinessData.dll assembly out of GAC. To do so: Start->Run, type in C:\Windows\assembly\gac_msil. Find Microsoft.BusinessData folder, and then copy Microsoft.BusinessData.dll to folder C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI.
    2. Add the following two assembly references to your project:
      1. In .Net tab, select Component Name = System.Web, Version=2.0.0.0.
      2. In Browse tab, navigate to folder C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI, and then add Microsoft.SharePoint.dll and Microsoft.BusinessData.dll.
  5. Set BDC SPI (SharePoint item) property. In Solution Explorer, select the SPI folder (e.g. “BdcModel1”), open Properties Window and update the following two Feature Receiver properties:

    C# Project -
    - Assembly = $SharePoint.Project.AssemblyFullName$
    - Class Name = BDCModelReceiver.Features.Feature1.ImportModelReceiver

    VB Project –
    - Assembly = $SharePoint.Project.AssemblyFullName$
    - *Class Name = BdcModelProject1.BDCModelReceiver.Features.Feature1.ImportModelReceiver
    * Replace “BdcModelProject1” with your own project name

  6. Set Feature property. In Solution Explorer, expand Features\Feature1 folder, double click on Feature1.Feature and open Properties window and update the following Feature property:

    C# Project -
    - Receiver Class = BDCModelReceiver.Features.Feature1.ImportModelReceiver

    VB Project -
    - *Receiver Class = BdcModelProject1.BDCModelReceiver.Features.Feature1.ImportModelReceiver
    * Replace “BdcModelProject1” with your own project name

  7. Now you can deploy the BDC project (Project->Deploy) or debug the BDC project (F5) to SharePoint Foundation 2010. You will find the external content type being deployed to the metadata store.

For more information about Business Connectivity Services, please also check out BCS Team blog.

Rong Lu