Working with external content types isn’t as straight forward as it should be, especially within a Visual Studio project. Take trying to define the display order of your columns as an example.
You define your task entity by adding your required Type Descriptors in BDC Explorer. The order the columns will display in external views is dependant on the order they are listed in the BDC Explorer. That’s all well and good but there’s no way through the UI to change this order.
The easiest way to change the order is to directly edit the dbcm file in your favourite text editor, mine is Notepad++. Other text editors are available 🙂
In Visual Studio, right click your model in the Solution Explorer pane and click Open Folder in File Explorer. In the folder that loads, open the bdcm file in your editor of choice.
Looking to design your own external content type and deploy it as part of a SharePoint solution? Read on for a walkthrough on how to create one.
First up, the steps are the same for SharePoint 2010 and 2013 and have been carried out using Visual Studio 2012. Visual Studio 2010 will also work.
Before I start the walkthrough, I’ll summarise the goal of this post:
We have a very simple database that contains a couple of tables – Customer and Order. An external content type will be created and via a view on the database, will return a list of customers and their orders. The external content type will only allow read access to this information.
- There is a Business Data Connectivity service up and running on the SharePoint farm for the External Content Type (ECT) to be deployed to.
- The user deploying the solutions containing the ECT, in this case the user running Visual Studio, has adequate permissions to create it in the application service.
- This is just a demonstration, so there will be a distinct lack of logging, error handling and bad practices such as storing database credentials in plain text within the code, try to ignore this 🙂
Over the past few months, I’ve been surprised by the number of people I’ve spoken with who were not aware that it’s possible to store custom XML documents against content type objects through the API. These are people who have either been developing of providing consultation for the platform since, at least, the release of MOSS 2007.
So, for that reason, I’ve decided to write a short post about the functionality.
The SPContentType class contains a property called XmlDocuments.
This property exposes a collection of XML documents that are stored against the content type. Although there can be a number of XML documents in this collection, it is also possible to add your own XML documents to the collection.