다음을 통해 공유


How to: Create a .NET Connectivity Assembly

Applies to: SharePoint Server 2010

Prerequisite: Read the Creating .NET Connectivity Assemblies and Web Services topic in this SDK.

If your external system is not directly supported by Microsoft Business Connectivity Services (BCS), you can expose your external system via Business Connectivity Services by writing code. If the entities in the external system are static and do not change often, and have a small set of known types, you can write Web services or .NET connectivity assemblies to expose the data from your external system in the format Business Connectivity Services best understands. To decide whether you should write a Web service or a .NET connectivity assembly to expose external data, see the table that compares and contrasts the two approaches in Creating .NET Connectivity Assemblies and Web Services.

However, if the entity model in the external system is dynamic, has custom types, and is large-scale, you should consider creating a custom connector for that data source type. For more information, see Differences Between Using the .NET Assembly Connector and Writing a Custom Connector.

Writing a .NET connectivity assembly involves the following tasks:

  1. Create the .NET connectivity assembly:

    1. For each external content type, create a class and define the fields it should contain.

    2. Add methods to the class to define the stereotyped operations you want to support for each external content type. For more information, see Creating .NET Connectivity Assemblies and Web Services.

    3. Compile the classes into a primary DLL.

    4. Compile as many dependent assemblies as needed for the primary assembly.

      Note

      The types that are referenced from the BDC model must be defined in the primary assembly. Dependent assemblies are usually used for helper methods or utility functions. They should not contain the definitions for the types referenced from the BDC model.

  2. Publish the .NET connectivity assembly and any dependent assemblies into the Business Data Connectivity (BDC) service database by using solution package (.wsp) deployment or by using Windows PowerShell cmdlets provided by SharePoint 2010. For more information, see How to: Publish a .NET Connectivity Assembly to the BDC Metadata Store.

Now you can use Microsoft SharePoint Designer 2010 to discover the .NET connectivity assembly and create external content types defined in the assembly.

Tools and Resources for Creating a .NET Connectivity Assembly

Prerequisite: Read Creating .NET Connectivity Assemblies and Web Services.

Microsoft Visual Studio 2010

Microsoft Visual Studio 2010 provides a special project template called Business Data Connectivity Model that provides a set of visual designers and code management to enable you to create .NET connectivity assemblies and author external content types based on them. A notable aspect of the tool is that it encapsulates the SharePoint specifics so you that you do not need to be a SharePoint expert to create very powerful external content types.

To learn about how to create a .NET Connectivity Assembly using Visual Studio 2010, see the following topics: