Mastering Business Connectivity Services in SharePoint 2010

Posted by: Mark Kendall , on 1/6/2011, in Category SharePoint
Views: 62757
Abstract: This article demonstrates how to build your own Business Connectivity Services (BCS) SharePoint 2010 components, "connectors"

They call me the “Connector guy”- affectionately of course- where I work, because I am like a Business Connectivity Services (BCS) machine when it comes to crunching out connectors to legacy systems. So I thought I would take the time to help others get over the learning curve of leaning to use BCS.

After reading this article, I hope you will agree that creating External list to data is just a walk in the park-like most tasks developers do, when they get the hang of it. The following chart is a good reference and depicts nicely that many tasks can be performed using the BCS architecture. In fact, almost any tasks can be performed using simple lists exposed by Business Connectivity Services (BCS) Services. In fact, “Everything is a list”, is one of my popular sayings.

BCS Architecture

BCS SharePoint 2010 Architecture

Original Image Source

So if everything is a list, then let’s get started building some lists!

Note: I am going to assume that you have a development environment set up- probably on a virtual machine, and that you have an instance of SharePoint 2010 on that machine. Microsoft has simplified the development process greatly, but requires a lot of software installed as a prerequisite to getting started with SharePoint development. Ah, the pains of being a Microsoft developer!

Anyway, fire up VS 2010 and select File, New, and Project from the file menu. Again, Microsoft has done a nice job of creating templates for a lot of the SharePoint objects required to be successful in this environment- and yes, there is a BCS Template:

Business Data Connectivity Model

After selecting Business Data Connectivity Model from the SharePoint 2010 list and naming the project whatever you want, you will and up with the good, start towards creating a connector that will be exposed as a list on your SharePoint site:

SharePoint Connector

I know what you’re thinking. This looks like any other template, with very little functionality and a lot of work to get it in shape to work in a real-world environment. Am I right? Well, your thinking is correct, but that is the reason I am writing this article. I thought the same thing, and as it turns out there a lot of little nuances in creating a “good connector”, and I will show the best way that I have found- and you can modify my model to fit your style.

Note: I think you will find using BCS, that taking small steps is going to prove to be a better strategy then plowing through all the steps and getting to the end, only to have a connector that is throwing errors and not being able to figure out how to fix them-(The correlation id problem- more on that later.)

So here is the first small step: Let’s rebuild the solution and deploy it to SharePoint - we will find out many things from this simple task:

1. Will the project compile without error?

2. Will it deploy to SharePoint?

3. Can we set the appropriate security settings on our BCS Component?

4. Can we create an External list in SharePoint using this BCS Component?

If all the steps go well and run without error, then we will be able to begin creating custom BCS components. The steps are as follows

Step 1 - Rebuild the solution
Step 2 - Deploy the solution
Step 3 - Set the permissions
Step 4 - Create External List in SharePoint 2010
Step 5 - Preview the list

Let us explore these steps in details:

Step 1: Rebuild the Solution

Select build rebuild solution from the File menu

Step 2: Deploy the Solution

Select build deploy from the File menu

Step 3: Set the permissions

Open SharePoint Central Administration (http://yoursite:8080) in most cases

Click on application management > manage service applications > Business Data Connectivity Service and find Entity1 from the list- this is the entity that we just deployed

SharePoint BCS Model Permission

Click on Entity1 and you should see this screen:

SharePoint BDC Object

Click on set object permissions and give the appropriate rights to those who will be viewing the list

Step 4: Create the external list

Go to the main SharePoint site (http://yoursite) and click on site actions > view all site content > create, external list > create

Sharepoint External List

Click the second icon from the External Content Type and select Entity1 from the pop-up:

Sharepoint External Content Type

Select create and your list will be created

Step 5: Preview the list

Preview Sharepoint BCS List

Summary

Congratulation, you’re on your way to becoming the “connector guy/girl” at your company. Of course this connector doesn’t do much, but we have fulfilled all the steps required to our ultimate goal of making “everything is a list”. If you have gotten this far, and you are looking at the list we created above, then all the obstacles have been cleared to creating your own, more powerful connectors!

Part 2 Creating Custom BCS Components

Part 1 of this series put us in a position to start building our own BCS SharePoint 2010 components, “connectors” and Part 2 will show you how to create powerful custom connectors that are connected to a database-so look out for Article 2 in this series.

Update: Part 2 of this article can be viewed here Mastering Business Connectivity Services in SharePoint 2010 (Part 2)

 

Give me a +1 if you think it was a good article. Thanks!
Recommended Articles
Mark Kendall is a Software Engineer working in the Oil Industry in Dallas,Texas. He has been a programmer/developer for past 15 years specializing in .NET/C# development. Currently, he is a Sharepoint/Silverlight developer specializing in BCS Services. He has published a book on Dotnetnuke, and written several articles on many .net subjects. Apart from his passion for making money writing software to improve business, Mark enjoys ranting-and-raving about current events and taking long runs on the beach. He blogs at kendallsoft and can be reached at Kendallsoft[attherate]hotmail[dot]com


Page copy protected against web site content infringement by Copyscape


User Feedback
Comment posted by Suprotim Agarwal on Thursday, January 6, 2011 3:20 AM
Nice article Mark and well written!
Comment posted by Ramon Coyier on Thursday, January 6, 2011 5:50 AM
Good article. I have an external list that uses Bcs to connect to a source and I use a web service to  insert the data. The issue is that although the source gets the updated value, the field is blank in the edit mode of Bcs. Any reasons why this happens? I am not the only one who faces this issue. A quick search on google shows similar issues including a q&a on stackoverflow, but the answers were not of any help. I am hoping you could throw some light on this
Comment posted by Henry Miller on Monday, January 10, 2011 6:01 AM
With reference to what Ramon asked is there a way we can enable logging here which can identify these issues of fields going blank. Is there anything available out-of-the-box? Although we are able to fix these issues, it takes a long time and a loggig mechanism will be able to pin point errors
Comment posted by Mark endall on Tuesday, January 11, 2011 12:03 PM
Good comments so far- I will address both issues in my next article.
Comment posted by Mark endall on Tuesday, January 11, 2011 12:03 PM
Good comments so far- I will address both issues in my next article.
Comment posted by Batto Heather on Friday, January 14, 2011 12:21 PM
5/5. Looking forward to see an example that connects the custom connector to a db!
Comment posted by kendallsoft on Friday, January 14, 2011 2:14 PM
For my next article I am creating a BCS that call a webservice to do the CRUD operations to answer some of the comments- I am able to get the updated field to show in edit mode- here is a preview of some of the things I had to do:
Web Service:

Place Web Service on non-sharepoint site
Add end endpoints to web config on Sharepoint site for web service
Change web config on sharepoint to NTLM for above service

SharePoint:
Create/Add default forms for new and update in sharepoint designer
Add new methods for above to BCS connector

Sharepoint
Make Identifier read only on readlist and readitem in the designer
On Model Set identifiers as update methods: updater feild preupdater fiels to true

Web Service: Implement the CRUD methods:

Database:
No changes
Comment posted by Rumesh Srivastav on Wednesday, December 21, 2011 1:47 AM
Hi,

I was reading your article and I would like to appreciate you for making it very simple and understandable. This article gives me a basic idea of Business Data Connectivity service in SharePoint 2010. Check out this link too its also having a wonderful post on business data connectivity services in sharepoint......
http://mindstick.com/Articles/049081ce-2993-4d31-81f8-b1e7d7ed7599/?Business%20Data%20Connectivity%20service%20in%20SharePoint%202010

Thank you very much!

Post your comment
Name:  
E-mail: (Will not be displayed)
Comment:
Insert Cancel