I came up with this nice scenario where a user wanted to import the ListData.svc from SharePoint as an External Content Type in SharePoint.
The requirement was to use a List as an External List in a different site collection.
The first thought that will cross the mind is that you can use SharePoint Designer to import a WCF Service. But ListData.svc cannot be imported in SharePoint Designer.
There are numerous ways to import a ListData.svc and one of the ways mostly talked about is to consume the service in a .NET assembly and import the .NET assembly as a External Content Type. That would work too.
But I was keen in finding a more easier way where I can create a model file and import it in the BCS Service Application through Central Admin site.
Well for that you have to create the model file first. Manually creating the .bdcm file? Tedious !! I would say.
Well I used Visual Studio 2012 to do it for me. Yes!! Visual Studio 2012!!
Follow the steps below to create the .bdcm file.
1. Open Visual Studio 2012 & Create a new SharePoint App Project.
2. Provide the necessary details for Name and the deployment site.
3. Select the type as SharePoint hosted
4. Once the project is created, “Add Content Types for an External DataSource ..” by right clicking on the project and navigating to the Add Menu and choose the last option.
5. This will bring up a screen where you can provide the URL for the OData Service and provide a name.
6. Enter the ListData.svc URL you want to use in the OData Service URL box and provide a desired name for the Data Source.
7. SharePoint will try connecting to the Service and List the entities available.
8. Select the Entity (List) you want to use, and click Finish.
9. Visual Studio will create the External Content Type and the list instance for you (if you had selected the check box)
10. Now Select the Content Type by navigating to the folder created in Visual Studio. The file extension is .ect.
11. View the Properties of the file in the Properties Window.
12. We are going to set the credentials that the BCS Service Application is going to use to call the service. We are going to use a Secure Store Target Application to store the credentials and use it. Lets Assume we created the Secure Store Target Application with the name “ListAccessAccount”. Now in the Properties window for the .ect file in Visual Studio, we are going to set the credentials for Windows Authentication Access using the windows credentials stored in “ListAccessAccount”.
13. Set the value for both the properties - “ODataServiceAuthenticationMode” and the “ODataServiceMetadataAuthenticationMode” as WindowsCredentials.
14. Set the value for the property “SsoProviderImplementation” as “Microsoft.Office.SecureStoreService.Server.SecureStoreProvider, Microsoft.Office.SecureStoreService, Version=184.108.40.206, Culture=neutral, PublicKeyToken=71e9bce111e9429c”
15. Build and Publish the APP. Don’t worry we are not going to import the App.
16. Now navigate to the project’s folder and use windows search to search for “*.bdcm” file in the folder.
17. You will find only 1 file with the name BDCMetadata.bdcm
18. Open the file in a text editor (notepad.exe).
19. Now do a find for “SsoProviderImplementation” in the notepad.
20. You will find 2 places where the property is defined. We are going to add our own property just above the found property. The value of the Property should be as below: (Note the value I am using ListAccessAccount. You need to change the value to the name of the Secure Store Target Appliaction you created)
<Property Name="SsoApplicationId" Type="System.String">ListAccessAccount</Property>
21. After adding the property it should look like below. Make sure you have added the property twice where you found the “SsoProviderImplementation” property.
22. Now we are done with the .bdcm file.
23. Next navigate to the BCS Service Application in your Central Admin site and import the model file.
24. Done !!
25. Once the import has happened you should see your BDC model, External System and External Content Type.
26. You can create list based on your External Content Type through the SharePoint UI by creating an External list.
Note – We are using Windows credentials in the Secure Store Target Application as we started on the assumption that the SharePoint Web Application from which we are going to consume data is using Windows Authentication.
Hope this helps some one out there !! Its going to be there for my reference for sure..