Share via


How to: Create an External Content Type by Writing a .NET Connectivity Assembly

Applies to: SharePoint Server 2010

In this article
How to Create a .NET Connectivity Assembly
How to Extend an External Content Type Created in Visual Studio 2010 Using SharePoint Designer 2010
How to Create an External Content Type Based on a .NET Connectivity Assembly Using SharePoint Designer 2010

If the external system is not directly supported by Microsoft Business Connectivity Services (BCS), you can create an interface to your external system by writing Microsoft .NET Framework code. If the entity model is static and has a small set of known types, then you can write Windows Communication Foundation (WCF) services, Web services, or .NET connectivity assemblies to interface with your external data source. If you decide to write a WCF service or Web service for your external system, Business Connectivity Services will not host the WCF service or Web service. You must host the service. Instead of writing a Web service or WCF service, you can create a .NET connectivity assembly with the back-end logic and publish it (with any other assemblies it depends on) to the BDC Metadata Store by using Microsoft Visual Studio 2010. Business Connectivity Services will host the .NET connectivity assembly by using the .NET Assembly Connector.

Note

However, if the entity model is dynamic, has custom types, and is large scale, you can create a custom connector for that data source type. For more information, see Differences Between Using the .NET Assembly Connector and Writing a Custom Connector.

The .NET connectivity assembly code should expose the stereotyped operations that Business Connectivity Services understands. See Stereotyped Operations Supported by BDC for more information about the stereotypes.

Writing a .NET connectivity assembly involves the following tasks:

  1. Write code as Microsoft .NET Framework classes and compile the classes into a primary DLL and multiple dependent DLLs.

  2. Publish the DLL into the Business Data Connectivity (BDC) service database by using solution package (WSP) deployment or by using Windows PowerShell cmdlets provided by SharePoint 2010.

  3. Use Microsoft SharePoint Designer to discover the DLL and create a model.

  4. Map each entity to a "Class" in the DLL, and map each BDC operation in that entity to a method inside that "Class".

  5. At run time, when a user executes a BDC operation, this executes the corresponding method in the primary or in a dependent DLL.

How to Create a .NET Connectivity Assembly

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

How to Extend an External Content Type Created in Visual Studio 2010 Using SharePoint Designer 2010

You can edit an external content type that was created and deployed by using Visual Studio 2010 in SharePoint Designer 2010. You would typically need to do this if you want to attach Microsoft Office client features to the external content type, such as map the external content type to a Microsoft Outlook item type and to enable offlining. To do this, perform the following steps:

  1. In SharePoint Designer, open the SharePoint site that contains the external content type.

  2. Click External Content Types, and then click the external content type you created by using Visual Studio.

  3. In the Office Item Type field, select the appropriate Outlook item type that this external content type maps to.

  4. In the Offline Sync for External List field, select Enabled.

  5. Click the Operations Design View button on the ribbon to edit the Read Item operation. Map the return parameters of the Read Item operation to the appropriate Outlook properties.

  6. Click Save to save the changes to the BDC Metadata Store. Now you have extended the external content type you created by using Visual Studio 2010 with client and offlining features.

How to Create an External Content Type Based on a .NET Connectivity Assembly Using SharePoint Designer 2010

There might be cases where you already have a .NET assembly that contains methods that return external data in the proper shapes that BDC expects. In such cases, you can deploy the assembly to the BDC Metadata Store and then simply use the External Content Type Designer in SharePoint Designer 2010 to create an external content type that connects to a .NET assembly. The procedure to create an external content type that connects to a .NET assembly is similar to one that connects to a Web service or WCF service.

  1. Open SharePoint Designer and follow the steps described in How to: Create an External Content Type Based on a Web Service to create an external content type. Except for the procedure "Add a connection to the external system", everything else is exactly the same. To add a connection to a .NET assembly, perform the following steps.

  2. Select Click here to discover external data sources and define operations next to the Connected System.

  3. In the Add Connection dialog box, click .NET Type.

  4. In the .NET Type Selection dialog box, click the Browse button to specify the External System (LOBSystem) in the BDC Metadata Store that contains the reference to the .NET assembly you want to connect to. Select the system and click OK.

  5. You should now be able to see all the public .NET types defined in the assembly and the methods contained by them. Define the operations as you would for a Web service, as explained in How to: Create an External Content Type Based on a Web Service.

  6. Click Save to save the changes to the BDC Metadata Store. Now you have created an external content type that connects to a .NET assembly.

See Also

Tasks

Code Sample: AdventureWorks2008 .NET Assembly