4. Using Visual Studio 2012 with BCS
BCS
is all about bringing data that lives outside SharePoint into
SharePoint. The BCS provides connectivity to your external LOB systems
by using connectors.SharePoint Designer was
used as a no-code method to define the BDC model and use ECT as
external lists and external data columns. This method has some
limitations:
-
You can only create CRUD operations. BCS supports other operations
that cannot be created using SharePoint Designer, such as the stream
operation that allows you to access a file that is stored as a Binary
Large Object (BLOB) in a SQL database.
-
The declarative XML created in the BDC model can be amended only if
you export the BDC model and then open the file created by the export
activity in SharePoint Designer. You would then need to know the BCS
model schema to amend the XML. SharePoint Designer does not provide any
no-code assistance in editing the BDC model XML file.
-
External lists cannot be used to represent any hierarchy or
relationship between the content that is stored in the external
systems. The data is presented as a flat, table-like structure; there
is no inbuilt tree-like or folder structure that you can configure to
match the relationship between the content.
-
SharePoint Designer only allows the use of SQL Server, .NET assembly, and WCF connectors.
-
SharePoint Designer does not allow you to create the VSTO add-ins
that could provide extract functionality to work with the external
content.
Visual Studio 2012 includes additional tooling for BCS—the
SharePoint Customization Wizard—that was not included in Visual Studio
2010. You can use this wizard to create an OData BDC model and the BDC
model operations that match the external system operations exposed via
the OData endpoints. The Visual Studio wizard creates ECTs with fewer
steps than it would take you to create ECTs in SharePoint Designer.
Unfortunately, you cannot create or modify an OData ECT with SharePoint
Designer.
To create a BDC model based on an OData producer using Visual Studio, complete the following steps:
-
In the Solution Explorer, right-click the project name, select Add,
and then click Content Types for an External Data Source to display the
SharePoint Customization Wizard page, as shown in the graphic on the
following graphic.
-
On the Specify OData
source page of the SharePoint Customization Wizard (shown here), type
the OData Service URL and the Data Source Name.
-
Click Next.
Visual Studio connects to the $metadata endpoint and then displays
the data entities available from the OData provider on the Select The
Data Entities page. Use this page to select those entities to include
in the BDC model and then click Finish, as shown next.
In the Solution Explorer, under External Content Types, you will see
the data source that you entered on the Specify OData Source page. When
the data source is expanded, as shown in Figure 12, there is an ECT for each data entity selected on the Select The Data Entities page.
Note
Visual Studio automatically generates the OData ECTs to use https, and therefore, the ECTs need to be amended if your OData provider endpoints use http.
When the Create List Instances For The Selected Data Entities check
box is selected on the Select The Data Entities page, an External List
definition (Elements.xml) is created and shown in the Solution Explorer.
The ECT files can be opened to display their contents as XML, or if
you double-click an ECT file, it will open in Designer view, as shown
in Figure 13.
The Designer view allows you to easily configure the columns for the
ECT and to add filters that you can use to limit the data that is
returned from the data source. A filter named Limit is generated
automatically with a default value of 100.