How to: Deploy a Declarative BDC Model with a Feature

Overview

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.

Note

For a practical example that uses this approach, see the External Data Reference Implementation.

Steps

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

  1. Open the Visual Studio 2010 project that contains your feature.

  2. In Solution Explorer, right-click the project node, point to Add, and then click New.

  3. 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.

    Ff798309.36b3a54a-1576-4e9a-ac0c-dded45e37f7a(en-us,PandP.10).png

    By default, the Business Data Connectivity Model item will add a new <projectname>.bdcm file and associated entity classes.

    Ff798309.ddfa213f-9c58-4e4d-8398-8a84a6f45649(en-us,PandP.10).png

  4. Delete the default <projectname >.bdcm file and entity classes.

  5. Right-click the Business Data Connectivity Model project item, point to Add, and then click Existing Item.

  6. Browse to your existing model file, and then click Add to add the existing model.

  7. 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.

    Ff798309.9bb12095-8e0b-4d4e-89e2-85eefe1280ad(en-us,PandP.10).png

  8. Right-click the Business Data Connectivity Model project item, and then click Properties.

  9. Click the Feature Properties ellipsis button (…) in the Properties dialog box.

    Ff798309.b1323a1f-da1d-46a0-8608-8abeb6e0ae55(en-us,PandP.10).png

  10. 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.

    Ff798309.1d4c00ed-bfad-411f-b045-3fcb4bc42c4e(en-us,PandP.10).png

  11. 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.

  12. Use the Properties dialog box to change the folder name for the feature. Make sure that the feature is farm scoped.

  13. Add your BDC model item to the feature.

    Ff798309.a385943d-c4a3-4aa2-ac41-b54d981d0e9e(en-us,PandP.10).png

  14. Right-click the Visual Studio project, and then click Deploy. Your BDC model should now be packaged and deployed successfully to your SharePoint farm.