External list using an OData Source in SharePoint 2013 based on a Farm wide BCD Model

This article describes how to create a SharePoint 2013 BCS model using an OData Source with Visual Studio 2012, import this model in BCS which can be used Farm wide and which is not limited to the scope of an app.

Currently you have the following options to create an external list using an OData Source:

  1. In Visual Studio 2013 create a new App for SharePoint 2013 project and use Add, Content types for External Data source to start the Visual Studio 2010 wizard.
    The downside of this option is that you are limited to the scope of the app. You cannot use the external list somewhere else.
  2. In Visual Studio 2013, create a SharePoint 2013 solution, add a Business Data Connectivity Model and build it all manually.

There is currently no support of OData sources in SharePoint Designer 2013 and there is even no toolset or wizard to generate the BDC Model in Visual Studio 2013 for use in a Farm solution.

But there is an easy way to generate this model and add the external list:

  • Create the app project from point 1 (The steps are well documented in MSDN http://msdn.microsoft.com/en-us/library/jj163967(v=office.15) and a lot of blog posts.)
  • Deploy it to generate the SharePoint solution file – wsp. The app itself is not used further.
  • Rename the wsp file to cab and extract or copy the BDCMetadata.bdcm file
  • Import this file in Central Administration / Manage service applications / Business Data Connectivity Service
  • Go to you site, Add an App / External List, Pick a Name and select an External Content Type with the External Content Type Picker

Please keep in mind, that SharePoint needs access to the OData Source even when you import the model! If SharePoint cannot access the OData Source you will get an import error like Application definition import failed. The following error occurred: The remote name could not be resolved: ‘services.odata.org’ Error was encountered at or just before Line: ’58’ and Position: ’20’.

If you want to use this in a production environment, you should change the name of the model. I even recommend to repackage the bdcm file into an appropriate SharePoint 2013 solution and Feature.

Nov 13 2012

At this time you can only generate this with Visual Studio 2012 RC (in RTM the SharePoint Customization Wizard shows an One or more errors occurred – error. Sometimes you are able to retrieve the data entities, in this case an No entities or function imports were found. BDC model will not be generated – error occurs after you press finish.)

With the new published version of the developer tools you can generate the model with RTM also: Microsoft Office Developer Tools for Visual Studio 2012 – Preview 2

Posted in BCS, OData, SharePoint Server 2013 | Leave a comment