Friday, June 22, 2012

Visual Studio 2010 and BDCM: How to build and deploy

During upgrade from SP2007 to SP2010, we have decided convert 2007 BDC files into 2010 BDCM files.

We did it using hybrid BDC upgrade approach

The exported BDC files I have added to SharePoint project in VS 2010
Creating a Business Data Connectivity Model

The article says each SharePoint project can contain only one model.

It's not true.

You can have as many models as you want in the one visual studio 2010 SharePoint project. 
Just create one project item per feature.

For an example, if you want shipped 10 BDCM models, create 10 features in the project.
Place one project item with BDCM model in each feature.

Identical feature property values from all project items are merged together in the feature manifest. However, if two different project items specify the same feature property key with non-matching values, a validation error occurs.

<Property Key="ModelFileName" Value="BdcModel1\BdcModel1.bdcm" />
So, remember - One project item per feature.
As you may know 2010 SharePoint Foundation allows to use BDCM. But there is one caviat with developing BDCM models in VS 2010 for SharePoint Foundation:

BDC deployment relies on feature event receiver to take care of actions like model import/feature activation. Unfortunately the assembly where the feature event receiver lives does not ship with  SharePoint Foundation. And the reason for that is same assembly has other functionality Microsoft decided not to ship in Foundation.

But, you have a solution to make it work:
 Deploy a BDC Model project to SharePoint Foundation 2010 using Visual Studio 2010
  Publish BDC Model project to SharePoint Foundation 2010 with Visual Studio 2010