By Tomek Stojecki, Stefan Kowalewski, and Ethan Wilansky

Problem: You develop a Business Data Catalog (BDC) Application Model in SharePoint 2010 and frequently delete the model to ensure that changes following a re-deployment propagate to the development environment. You need to automate the task to save time.

Solution: When developing Business Connectivity Services (BCS) solutions that use a .NET Connectivity Assembly or custom assembly, you might need to delete a BDC Model to ensure that all the updates make their way into the  SharePoint environment. You could navigate to Central Administration, Application Management, Service Applications, Business Data Connectivity Service, and select the BDC Models option from the drop-down menu in the Ribbon; then select a BDC Model and click the Delete button on the Ribbon. However, completing this task repetitively from the UI is a waste of time.

Instead, create the following script and run it from the SharePoint 2010 Management Shell console. The script requires two parameters: one for the name of the BDC model and the other for the service context URL, which, in this case, is the URL of the SharePoint Central Administration site hosting the model. The script then calls into the Get-SPBusinessDataCatalogMetadataObject and Remove-SPBusinessDataCatalogModel commandlets that ship with SharePoint 2010 to retrieve and delete the model respectively.

    \\[string\\]$bdcModelName = $(throw "You must specify the name for the BDC Model. For example -bdcModelName:BdcInvoicingModel"),
    \\[string\\]$context = $(throw "You must specify the service context (central admin url) containing the lob instance. For example -context:http://spdev:30000")

$model = Get-SPBusinessDataCatalogMetadataObject -Name $bdcModelName -BDCObjectType Model -ServiceContext $context
if($model) \\{       
    Remove-SPBusinessDataCatalogModel -identity $model -Confirm:$false
else \\{
    write-host “The $bdcModelName Bdc Model could not be found”

In addition, you can load the SharePoint PowerShell snap-in from within the script, which allows you to run the script without going into the SharePoint PowerShell Management console. You can load the snap-in in the following way:

Add-PSSnapin "Microsoft.SharePoint.PowerShell"


Read more SharePoint Q & A's :

SharePoint Q&A: Attempting to Configure Search Scope Settings for a Site Collection Throws an Error

SharePoint Q&A: How do I configure a load balancer to accept only SSL requests for a SharePoint 2010 FQDNs?

SharePoint Q&A: How Do I Apply a Filter Based on a URL to an External List?

SharePoint Q &A: How Do I Propagate BDC Model Updates to an Entity Picker to Resolve the "Parameter is Missing" Error?


SharePoint Q&A: How Do I Smoothly Deploy Reports Hosted in SharePoint?

Sharepoint Q&A: How Can I Create an External List When SharePoint Throws an Unspecfied ASP.NET Error?

SharePoint Q &A: InfoPath Designer 2010 message says By default this control will send data to the server whenever its value changes

SharePoint Q&A: How do I display a user-friendly value?

SharePoint Q&A: How do I display a more user-friendly error message?

SharePoint Q&A: How do I submit the InfoPath 2010 form programmatically to an external list?

Sharepoint Q&A: How Can I Create an Action for an External Content Type in SharePoint?

Sharepoint Q&A: How to Make a Type String Type Descriptor a Required Field in the BDC Explorer

Sharepoint Q&A: Data Source Conflict