TechBubbles Microsoft Technology BLOG

Creating Business Data Connectivity Model for SharePoint 2010 using VS 2010

 

This post discusses about how to connect .NET Connectivity Assembly for Business Connectivity services using Visual Studio 2010. Business Data Connection Model allows you to connect to the external data sources and can edit them directly from SharePoint site list. SP2010

 

The table that we are going read from the SQL Server are

image

Now Create a New Project in Visual Studio 2010 and select the Business Data Connectivity Model template from the dialogue box.

image

Choose deploy as a farm solution while creating the project

image

Visual Studio creates an entity for you as shown below

image

Rename the entity to TraningEvent and add some properties as shown below

By default it visual studio creates two properties Identifier1 and Message. We can override those properties with custom properties.

image

Switch back to BDC model designer as shown below, Rename the entity to TraningEvent Entity

image

You can edit the parameters of ReadItem input parameter and return parameter as shown below

Change the Identifier1 parameter name to TrainingEventId and data type to Int32. ReadItem is a specific finder where I can retrieve item from the database based on individual id Trainingevent.

Change the name of return parameter name from entity1 to TrainingEvent so that specific finder find an event to specific entity. Now setup the type descriptors for this event Add any other type descriptors to this event type like login name and title.

image

Do the same for Readlist method which finds multiple events and having the return parameter of type list item. You can also add create method using the dropdown list as shown below

image

Type descriptors will automatically setup for the method in BDC explorer just change the type names for the parameters

image

Similarly you can add delete method and update a method and click save changes.

image

Visual Studio Creates a sample code when you create methods where you can override that code with the custom logic by reading the items from the database

image

Similarly write logic for create, update and delete methods.

Now you can deploy the solution to SharePoint but before deploying check you are having proper administrative permissions in SharePoint Central administration and click manage service applications option

image

Click on the business connectivity services option

image

You can set the appropriate permissions for this BDC model

image

Now create an external list from SharePoint site as shown below

image

Select the external content type from the data source picker for the list as shown below

image

Click on create to save the list.

Now add some events to the list as shown below

image

image

Now you can notice the saved items in SQL server table

image

You can perform edit and delete operation on list and can check back the database for the same. More about the BDC can be read here

Share this post :

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

1 Comment

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud