I'm planning on creating a BCS layer which will be used in a multi tenant scenario. The plan is as follows: multiple clients will all get a SharePoint site. They will sync data from their ERP into a central database, which is then queried by BCS. The database is setup to be multitenant, so all records have a key which includes the tenant Id. I need to setup the BCS so that it only reads data with the correct tenantId, and never allows users to see data from another tenant.

What I have thought of is deploying the BCS model as an assembly and using the code to sniff the context of the call and use that contact to query the correct tenant. But I was wondering if this is fool proof. What would happen when for instance Word connects to the SharePoint environment and query the BCS?

Another approach would be to deploy the BCS sandboxed, so each site gets it's own BCS definition instead. In that case I can probably insert the tenant info into the definition and handle it that way. The only thing to look out for is that a user can never adapt the definition and paste in another id (which would be quite hard when using a guid).

Has anyone ever done this? What approach (maybe there are other ones even better) would you choose and why?

Edit: I've gone with the .net assembly approach to make sure all content is filtered based upon the current SPContext. But it wasn't untill first deployment that I found out that a partitioned BCS app doesn't allow DotNetAssembly type LOBsystems. You can import it fine, and create a new external list; but it won't load any data. Don't know why, don't know how to circumvent this. Either way, I'm kind of screwed now since this means my whole idea isn't feasible at all.

Edit 2 (and I'll create a blog post for this); you can work around the partitioned BCS approach by creating a non partitioned BCS app and including that in your proxy group. Apparantly there are no restrictions on calling a non-partitioned service app from a site subscription bound site (at least not for BCS).

3 Answers 3


Let me check your requirements: You have a multi tenant database full with information, and all information is provided with a tenantID. You DON'T have SharePoint have setup as multi tenant.

what users do have access to create new external lists? If that is only you (as developer, administrator), You could go with separate BCS models where you create a query/stored procedure which includes the tenant ID. For each site, create a new External list which can be used by the customer.

However, If you users do have access, it will become harder. Key is: do your customers have access to the BCS models or not? If they do have, then all I can come up with, is: use a custom .Net connector which handles which tenantID has to be used. That is quite a complex solution (I like to keep it clean and simple).

as far as i know is deploying a BCS model using a sandbox, not possible.

  • I do have SharePoint setup as a multi tenant environment, and I understood that it's possible to treat BCS as multi tenant as well when you upload the BCS to the specific web app? So creating a tailormade model would be the best option then I guess. Just need a good script for deployment, I'm not looking to do that manually each time.
    – Jasper
    Feb 24, 2012 at 15:58

I can think of two approaches:

1) Model the ECTs based on database views. You can create views based on TenantID.

2) Create and use ECT based on a WCF Service. Using WCF, you can provide access to data filtered by any business rules and security policies.

  • Thanks. Option 1) is far too much work. This would mean creating a view per tenant and adapting the model each time. Option 2) is too tricky. This would mean you would have to provide a filter value as a webservice parameter since the webservice won't have knowledge of the context in which the request was made. Passing in a parameter would mean site admins have the option to change that parameter, and that's definitely not an option I want to provide them with.
    – Jasper
    Mar 30, 2012 at 7:41
  • For second option, It is not necessary to pass id as parameter. Web service can have the context you want Mar 30, 2012 at 8:30
  • How would the webservice know where the call is coming from? In my opinion a webservice should never ever be context aware.
    – Jasper
    Mar 30, 2012 at 12:56
  • Check this out : blog.mastykarz.nl/wcf-sharepoint-context Apr 2, 2012 at 6:02
  • I cannot deploy to layouts, since it's a shared hosted environment. Deploying to layouts would make the service available for everyone with access to a random tenant site.
    – Jasper
    Apr 3, 2012 at 18:01

You can't make a filter when creating your External Content Types? You can do that through SharePoint Designer. Whatever the Tenant ID is you can filter it by the appropriate value, whether it be Username or other ID.

Also, you can create a database view that you can only grab items that have that specific tenant id and then filter through the BCS content and create an external content type based on that in SharePoint Designer. Each client can have his or her own tab with that External Content Type.

  • Same comment (same answer basically) as I gave to Amit; a filtervalue can be changed by site admins so that's not really an option. I need a foolproof 100% safe method which cannot be tampered with. Creating new views for each tenant is not good practice either.
    – Jasper
    Mar 30, 2012 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.