Home > SharePoint > CodeFluent Entities: Using your application in SharePoint 2010

CodeFluent Entities: Using your application in SharePoint 2010


SharePoint 2010 provides a great feature named the Microsoft Business Connectivity Services (BCS) (formerly known as the Business Data Catalog in SharePoint 2007).  SharePoint’s BCS enables users to read and write data from external systems from within SharePoint 2010 and to do so you need to create an External Content Type to bring external data in SharePoint. Once you have an external content type, you can use it with any of the various presentation features of Business Connectivity Services such as external lists, external data columns, and external content controls for Office applications.

External Content Types can be created from databases, WCF services or a .NET assembly, and it just so happens CodeFluent Entities can generate any of the three, therefore using SharePoint’s BCS feature you can, without a single line of code, consume your application in SharePoint 2010!

Form a bird’s-eye view here’s how to do it:

Create Your Application

Nothing specific there: use CodeFluent Entities to design your application and generate the code!

For this post, we used:

  • the SQL Server Producer to generate the database,
  • the Business Object Model Producer to generate our .NET classes,
  • the WCF Service Producer to generate our WCF services and contracts,
  • the Template Producer to generate our WCF configuration file, as well as SVC files to host our services in IIS.

image

 

Create an External Content Type

As a data source to our external content type we used our WCF services so that manipulating data in SharePoint still uses our business logic and we don’t have to deploy our dll in SharePoint.

Here’s how how to do it: How to create an External Content Type based on a Web Service.

image

 

Create an External List in SharePoint

Once you have your External Content Type, still using SharePoint Designer, you can create a SharePoint list from it as well as Forms to create, list, update and delete data in SharePoint by clicking on “Create List & Forms”. Here’s how to do it: http://msdn.microsoft.com/en-us/library/ee558778.aspx.

Note: you can also do it from SharePoint, but don’t forget to create the InfoPath forms or else you’ll only be able to list and delete data as you won’t have any forms to create and update it.

image

 

Set Permissions so users can use the BCS

At this point, everything is ready however if you try to access your list you’ll get this error:

Access denied by Business Data Connectivity

That’s actually normal: by default no user (even the one who created it) can access external data, you need to grant this permission explicitly.

To do this, go to: Central Administration -> Application Management -> Manage Service Applications ->Business Data Connectivity Service* -> [Your Entity] -> Set Permissions, and grant them to the desired accounts or groups. (Here’s a nice blog post with screenshots illustrating how to do it: Access denied by Business Data Connectivity solution).

 

Result

And taadaa!! Here’s your data in SharePoint:

image image

Furthermore, now that your data is in SharePoint you can do way more that just listing them or editing them, you can for instance:

 

Cheers,

Carl Anderson

  1. February 1, 2012 at 2:35 pm

    Hi,

    To clarify one point in the WCF Connection dialog box, you must set for the Service Metadata URL setting, the the URL of the service endpoint, appending the ?wsdl string to the end of the URL. For example: http://localhost:8000/MyCustomerService.svc?wsdl

    In the Metadata Connection Mode field, select WSDL.

    In the Service Endpoint URL field, type the service endpoint URL without the ?wsdl string. For example: http://localhost:8000/MyCustomerService.svc

    Otherwise, you’ll have an XML format error raised by SharePoint designer.

    Omid.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s