Tune Up Your PC

Tune up your PC with our tools and information today!

  • Home
  • About

10

Feb

Using Resource Files in BDC model

Posted by admin  Published in windows, xp

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

bdcmodel

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

bdcresource

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”

addbdcresource

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”

updateres1

Select “Business Data Connectivity Service”

updateres2

Select the “Import” option from ribbon

updateres3

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.
update4

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}"

   4:  

   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

Following TechNet articles might be helpful

  • http://msdn.microsoft.com/en-us/library/aa674515(office.14).aspx
  • http://technet.microsoft.com/en-us/library/ee524073(office.14).aspx
Technorati Tags: SP2010,BDC

Related Articles

  • I knew where Nepal was before Raiders of the Lost Ark. Did you? (September 3rd, 2010)
  • Steve Marx Reads The Azure Tea Leaves on Connected Show #36 (September 3rd, 2010)
  • Не место красит разработчика, а… (September 3rd, 2010)
  • Quote of the Day: On the Efficiency of Government (September 3rd, 2010)
  • What happens to a named object when all handles to it are closed? (September 3rd, 2010)

No user responded in this post

Subscribe to this post comment rss or trackback url

September 2010
M T W T F S S
« Aug    
 12345
6789101112
13141516171819
20212223242526
27282930  

Blogroll

  • Development Blog
  • Documentation
  • Plugins
  • Suggest Ideas
  • Support Forum
  • Themes
  • WordPress Planet

Categories

  • computers (59)
  • email (3)
  • hardware (17)
  • Operating Systems (1)
  • security (27)
  • software (87)
  • spam (2)
  • technology (93)
  • windows (12402)
  • wireless (3)
  • xp (12397)

Archives

  • September 2010 (75)
  • August 2010 (741)
  • July 2010 (904)
  • June 2010 (594)
  • May 2010 (776)
  • April 2010 (881)
  • March 2010 (728)
  • February 2010 (794)
  • January 2010 (645)
  • December 2009 (710)
  • November 2009 (625)
  • October 2009 (653)
  • September 2009 (622)
  • August 2009 (629)
  • July 2009 (627)
  • June 2009 (652)
  • May 2009 (607)
  • April 2009 (629)
  • March 2009 (465)
  • February 2009 (40)
  • November 2008 (157)
  • October 2008 (140)

Recent Entries

  • I knew where Nepal was before Raiders of the Lost Ark. Did you?
  • What happens to a named object when all handles to it are closed?
  • Quote of the Day: On the Efficiency of Government
  • Не место красит разработчика, а…
  • Steve Marx Reads The Azure Tea Leaves on Connected Show #36
  • This is a really cool panoramic stitching tool!
  • Microsoft Dynamics ERP Licensing Guide
  • Fortnightly MSDN Flash poll
  • Analyzing Database Roundtrips with SQL Server Profiler
  • Windows Identity Foundation Samples–HTTP Watch Is Your Friend

Recent Comments

  • No Comments
  • Random Selection of Posts

    • Increase your search rankings with better web page titles
    • Flash v Silverlight Gallery
    • VS2010: Profiling In Progress (PIP)
    • Windows Essential Business Server
    • SOA Manifesto
    • Creating Classrooms of the Future
    • OABGen with regards to public folders and backup’s
© 2008 Tune Up Your PC is proudly powered by WordPress
Theme designed by Roam2Rome