Using Resource Files in BDC model

Business Data Connectivity Service in SharePoint 2010 supports two types of files

  • Model (contains the base meta data for the LOB system)
  • Resource (enables you to import or export only the localized names, properties, permissions, custom environment settings in any combination)

Model File can also contain resources (properties, localized names, permissions), this is the most common scenario, every time we need to make change to the resources we update the model file and import it back to the BDC.

Few things you need to know when importing model and resource files

  • When you import a model file, BDC will overwrite the metadata which often results in having to retest your BDC based solution.
  • When you import the resource files the properties, localized names, and permissions are merged with the existing metadata.

What is the benefit of using resource files?

So by separating out model definition and resources in two different files, there are many advantages

  • Consider a scenario where your BDC application connects to a backend SQL Server database or a Web Service. In development environment “rdbConnectionString” property might contain connection information to development instance of SQL Server database, same is the case if your BDC application is talking to a web service, “WsdlFetchUrl” might be different depending on the environment. If model and resources are combined any time you have to change the connection information or update the wsdl url entire metadata will be updated even though nothing changed except the connection/wsdl url information. Having these properties in separate resource file one for each environment allows you to update the environment dependant settings without having to update the entire model
  • Keeping localized names in separate resource file also has its benefits when you want to support a new language, you can just create a resource file that contains localized names for the new language you want to support and update just the resources instead of entire model

In both scenarios mentioned above if the resources are combined with model,  making any change to resources would also result in updating the entire model even though there was no meta data change which would require you to re-test your BDC based solution.

Some additional things to note about model and resource file

If you exported model and resource out of BDC, in the xml file generated you will notice that the schema reference is different for model and resource

Figure below shows a sample exported model file, notice the reference to BDCMetadata.xsd schema


Figure below shows a sample exported resource file, notice the reference to BDCMetaDataResource.xsd


How can you create resource files?

In Visual Studio 2008/MOSS 2007 world there is no designer support to do this. Quick way to do this would be if you have an existing BDC application, you can just export the application and choose “resource” option and select all that apply. Three options you get are

  1. Properties
  2. Localized Names
  3. Permissions

Also export the model without the resource, select the model option during export. Going forward when there are changes in resources you update the resource files and when you have to change the model it self you would update the model file and deploy back into BDC

The other option is to use an xml editor and manually create the resource file, obviously this would require you to understand the schema very well. So the best option is to export the resources and model separately into different xml files.

In Visual Studio 2010/SharePoint 2010 however there is designer support to add BDC model file and BDC resource file as separate project items to your BDC project. Right click on the BDC model for which you want to add a resource file and select “Add->New Item”


Select the “Business Data Connectivity Resource Item” and click on “Add”

Updating Resources used by a BDC model

You can do this via CA user interface. The instructions below are for SP2010, but they are pretty much identical in MOSS 2007.

Once you are in central admin select “Manage Service Applications”


Select “Business Data Connectivity Service”


Select the “Import” option from ribbon


Click on browse and select the resource file, choose the resource option for file type and select all options that apply for resources. Your selection would depend on the combination you chose for your resource files. For instance if resource file contains only updates to properties you would select only properties and vice versa. Clicking on import will merge the settings from resource file with meta data.

Updating resource file using Object Model

following lines of code can be used to update resource file via object model.

   1: if (Microsoft.Office.Server.ServerContext.Current != null)
   2: {
   3:     string resourceFile = "{replace with your resource file name}"
   5:     //import the application definition file into business data catalog ;
   6:     ParseContext context = new ParseContext();
   7:     ApplicationRegistry.Instance.ImportPackage(resourceFile, context, Encoding.UTF8, 
   8:         PackageContents.LocalizedNames | PackageContents.Properties | PackageContents.Permissions);
   9: }

This functionality is not something new in SharePoint 2010, it existed in SharePoint 2007 version as well, but I think it was ignored by many of us since there was not much documentation, blog posts, examples etc around using resource files in BDC

I’m really glad to see some documentation exists now with SP2010 on this. Following TechNet articles might be helpful

Technorati Tags: ,

Comments (0)

Skip to main content