Today, we’ll learn to build BCS .Net Connectivity Assembly using Microsoft Visual Studio 2013 for SharePoint (In-Premises)
Let’s create a database ExternalDatabase in SQL Server with a table Employees. This has following columns:
- EmpNo – Primary Key, int type, not null
- EmpName – varchar(50), not null
- Department – varchar(50), not null
- Location – varchar(50), null
- Country – varchar(50), null
Let’s move to Visual Studio 2013 now.
Following are the steps:
- Create an Empty SharePoint project mapped with development SharePoint site and deploy as Farm solution option.
- Once Visual Studio solution is created, add new SharePoint item “Business Data Connectivity Model (Farm Solution)”. Provide name as ExternalEmployeeModel.
- Double click on ExternalEmployeeModel, it will open .bdcm file in design mode.
- Delete auto generated Entity and create new Entity named as ExternalEmployeeItem.
- Now add a new identifier “EmpNo” of type
- Add new class file and open
- Add all properties corresponding to columns in SQL database table. It will look like screen shot below:
- Now it is a time to add BDC methods. Click then select BDC Method Details tab at bottom.
- Select your entity and add a finder method
- Under parameters, select returnParameter’s type descriptor “ExternalEmployeeList” and edit. It will launch BDC Explorer.
- Expand “ExternalEmployeeList” in BDC Explorer. Then expand “ExternalEmployeeItem” and add all properties same as the properties added in ExternalEmployeeItem class.
- In the same way add other methods into this entity. Below screen shot will guide you, how should it look like.
- Now we’ll set required BCS Custom Properties.
To add this property, click ExternalEmployeeModel in Solution Explorer. In the Properties window, click on (Collection) next to Feature Properties and click the ellipsis (…) button. In the Feature Properties dialog, click Add. Set the Key property to SiteUrl and the Value property to the URL you selected in the SharePoint Configuration Wizard when you created the project. (Note: this should be the same value as the Site URL property in the project properties)
Note: We have to set a BCS Custom Property to allow us to successfully deploy the BCS model. For some reason, the SharePoint Configuration Wizard sets the Site URL project property, but doesn’t create the SiteUrl property in our Feature that is needed for successful deployment.
- Now we’ll set Title property of BCS Model. Next, we’ll set the Title field for the entity. If this BCS Custom Property is not set, any search results that are returned from this content source will have the name of the BCS Profile Page as the title, and they will all be identical. This makes the search results less valid.
In the BDC Explorer tool window, click ExternalEmployeeItem under Model –> ExternalEmployeeModel –> ExternalEmployeeModel. Click (Collection) next to Custom Properties in the Properties tool window and click the elipsis (…) button.
- Deploy the project
Configuring External Content Type in BCS Service Application
Open up Central Administration on your SharePoint 2013 instance, and navigate to your BCS Service Application Instance. (Central Admin –> Manage Service Applications). If the .NET Connectivity Assembly has been successfully deployed, you will see the ExternalEmployeeItem entity listed in the table as below:
Click the checkbox next to the ExternalEmployeeItem entity in the table, and click the Configure button on the toolbar in the Profile Pages section. In the Configure External Content Type Profile Page Host select the SharePoint site where you want your ECT Profile Pages created. Click OK at the bottom of the popup window when done.
Check the checkbox next to ExternalEmployeeItem in the table and click Create/Upgrade in the Profile Pages section of the toolbar.
A Loading… popup window will appear while the profile pages are created. When completed, an informational dialog will appear. Click OK. Another window will be displayed when the profile page has been successfully created.
Next, check the checkbox next to ExternalEmployeeItem again, and click Set Object Permissions in the Permissions section of the toolbar.
In the Set Object Permissions box, add appropriate permissions for the search service account, content access account, and any app pool accounts for any web applications that will be using, consuming, or displaying data from the ExternalEmployeeItem External Content Type.
Now you can create External list corresponding to this external content type and use CRUD (Create, Read, Update, Delete) operations on external data.
Like & Share…
THREE QUERIES offers easy access to information about SharePoint and associated technologies, project management, agile and scrum methodologies that helps developers, administrators, architects, technical managers, business analysts and end users. It has grown from there. We provide an important knowledge base for those involved in managing, architecture and developing software projects of all kinds. With weekly/daily exclusive updates, we keep you in touch with the latest business, management, technology thinking.
WE ARE CONNECTED ~ Follow us on social media to get regular updates and opinion on what's happening in the world of SharePoint, front-end, back end web technologies and project management. If you like this article, please share it and follow us at Facebook, Twitter, Instagram and LinkedIn