How to: Deploy a Declarative BDC Model with a Feature
Another new feature of Microsoft® SharePoint® Server 2010 is the ability to build a Business Data Connectivity (BDC) model file that defines the connections, operations, and associations of an external line-of-business (LOB) system. You can deploy the BDC model as a SharePoint feature and package the feature as part of a SharePoint solution.
The Microsoft Visual Studio® 2010 development system provides tooling to help you construct and deploy BDC models that use a .NET connectivity assembly. If you create a Visual Studio project by using the Business Data Connectivity Model project template, Visual Studio builds the BDC model definition with the classes required for the .NET connectivity assembly. It will also create a deployment package for these components. However, in many cases you will not require a .NET connectivity assembly. A purely declarative BDC model will suffice for many common scenarios that access data in relational databases or from Web services that map to the stereotyped operations supported by the BDC. Typically, you will use SharePoint Designer 2010 to build the BDC model in these cases, because the Visual Studio Designer only supports building the BDC model for a .NET connectivity assembly. When you use SharePoint Designer to create a BDC model, you need to take some additional steps to import your BDC model (.bdcm) file into Visual Studio so that you can deploy and install the model as part of a SharePoint solution.
|For a practical example that uses this approach, see the External Data Reference Implementation.|
This procedure imports an existing .bdcm file into Visual Studio and deploys it as part of a SharePoint solution package. The procedure assumes that you have created a declarative BDC model, either by using SharePoint Designer 2010 or an XML editor, and saved it locally as a .bdcm file.
To create a feature to deploy a declarative BDC model by using Visual Studio 2010
- Open the Visual Studio 2010 project that contains your feature.
- In Solution Explorer, right-click the project node, point to Add, and then click New.
- In the Add New Item dialog box, under Installed Templates, click the SharePoint 2010 template type, and then click Business Data Connectivity Model in the middle pane. In the Name box, type a friendly name for the item, and then click Add.
By default, the Business Data Connectivity Model item will add a new <projectname>.bdcm file and associated entity classes.
- Delete the default <projectname >.bdcm file and entity classes.
- Right-click the Business Data Connectivity Model project item, point to Add, and then click Existing Item.
- Browse to your existing model file, and then click Add to add the existing model.
- Since the model file being added was generated using SharePoint Designer, you will receive a message asking if you want to add a .NET assembly LobSystem to the model. Select No, and then click OK.
- Right-click the Business Data Connectivity Model project item, and then click Properties.
- Click the Feature Properties ellipsis button (…) in the Properties dialog box.
- In the Feature Properties window, find the Feature Property with the name of the original BDC model item added when the solution was created. Select it, and then click Remove to remove it from the Property collection.
- Add a new farm-scoped feature to the Visual Studio project by right-clicking the Features item in the project, and then clicking Add Feature.
- Use the Properties dialog box to change the folder name for the feature. Make sure that the feature is farm scoped.
- Add your BDC model item to the feature.
- Right-click the Visual Studio project, and then click Deploy. Your BDC model should now be packaged and deployed successfully to your SharePoint farm.