15 October 2010

Issue when redeploying a BCS solution to SharePoint 2010

Problem:
I created a BCS solution within Visual Studio 2010 and deployed it to my SharePoint farm which worked fine. I later made some changes to the BDCM (BDC Model file) within my project and redeployed it to the server. I then got errors when calling the BDC connection in a  BDC data item web part, which referred to variables in the BDCM file that no longer existed. I did global searches in my solution and found no references anywhere to those old variables. Example error message:


TypeDescriptor with Name 'Identifier1' (found in Parameter with Name 'returnParameter', Method with Name 'ReadList', Entity (External Content Type) with Name 'Job' and Version '1.0.0.1' in Namespace 'Org.JobList') refers to an Identifier with Name 'Identifier1' of Type 'System.String' which is supposed to exist on Entity with Name 'Job' in Namespace 'Org.JobList'. This Identifier cannot be found.


Investigation:
After a bit of messing around I found that when I redeployed the solution, whilst it took care of retracting and deploying the solution then replacing the "External Content Type", it did NOT update the "BDC Model", which is the fundamental part, the XML definition, of your connection. So, the references to old variables were coming from the old version of the BDC Model.

Solution:
If you are deploying a new version of a BCS solution ,which includes changes to the BDCM file, you must do the following:
  1. Go to Central Admin > Application Management > Manage Service Applications
  2. Select Business Data Connectivity Service and click the Manage button
  3. In the drop down list at the top of the page select BDC Models
  4. Find the BDC Model that relates to your project and select Delete from its context menu
  5. Now Deploy your package from Visual Studio
  6. Don't forget to set permissions again on the External Content Type after deployment and check the "Propogate permissions to all methods...." checkbox when doing so
NOTE: If you haven't changed the BDCM file then there's no need to do this before deployment

3 comments:

  1. Thanks Mat...this was helpful

    ReplyDelete
  2. Don't forget to delete the "external Sytem" too

    ReplyDelete
  3. @ludovic: I realize it's waayyyy too late, but thank you so much. That solved my half hour headache ...

    ReplyDelete