Q: How do I deploy a Visual Studio Business Data Connectivity Model (BDCM) solution in SharePoint after changing the identity?
Problem: You’re developing a Business Data Connectivity Model (BDCM) solution in Visual Studio and need to change the identifier for an entity. When you deploy the model, you get the following error message, even after deleting the External Content Types and BDC Model from Central Administration:
Error 1 Error occurred in deployment step 'Add Solution': Model file 'Model\Contacts.bdcm' has the following External Content Type activation errors:
TypeDescriptor with Name 'Email' (found in Parameter with Name 'contact', Method with Name 'ReadItem', Entity (External Content Type) with Name 'Contact' and Version '220.127.116.11' in Namespace 'SharePoint.BdcModel.ContactsModel') refers to an Identifier with Name 'Email' of Type 'System.String' which is supposed to exist on Entity with Name 'Contact' in Namespace 'SharePoint.BdcModel.ContactsModel'. This Identifier cannot be found.
Solution: During the deployment the solution gets retracted, deleted, re-added and deployed. However, because the identity has been changed, the deployment fails during the add solution step because the type descriptor for the original identifier can’t be found. The reference to the original identifier exists in the feature, which still exists.
To successfully redeploy the solution, first delete the External Content Types and BDC Models. From the SharePoint 2010 Management Shell type the following:
$modelFile = Get-SPBusinessDataCatalogMetadataObject -Name ContactsModel -BdcObjectType Model -ServiceContext http://contoso Remove-SPBusinessDataCatalogModel -Identity $model
Next, disable and remove the feature. The GUID you’ll use will be different than the example below. You can use Get-SPFeature to get the identity for your solution. (NOTE: the feature may already be disabled.)
Disable-SPFeature -Identity 8b9b0eff-4fbb-4908-8f37-a47cb898309f -Force Uninstall-SPFeature -Identity 8b9b0eff-4fbb-4908-8f37-a47cb898309f -Force
Finally, uninstall and remove the solution:
Uninstall-SPSolution -Identity contactsmodel.wsp Remove-SPSolution -Identity contactsmodel.wsp
You will now be able to successfully deploy your solution.