Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a feature put together in Visual Studio 2010 that creates 3 external list instances. These get created just fine when the feature is activated, but upon deactivation they remain on the SharePoint site.

Is there any way to remove these list instances when the feature deactivates?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

You need to be extremely careful. SharePoint does not delete lists by default because it does not want to destroy customer's data. If the customer has added data to the list or "re-purposed" it then they will be very angry when you destroy their data.

When you say "External List Instances" I assume you mean BCS External Lists. If so then your list will not contain any additional data but the list instance might have been customized by the user (View or Query).

If you are you really sure you need to destroy the list and any customizations it contains then I would suggest an SPFeatureReceiver and on FeatureDeactivating use the object model to find the list and delete it.

share|improve this answer
    
Thanks Steve, you make a great point about being absolutely sure I want to remove the lists. This is my first delve into SP development and somehow I didn't think of that consequence ;) I was able to pull off what I needed to do after looking into SPFeatureReceiver. Thanks! –  MattG Nov 1 '10 at 15:50

Using the SPFeatureReceiver is the best way to remove the list on feature deactivation. I am assuming though that you want to remove the list on a development environment only? If so you could delete the list with a powershell script locally after the solution is redeployed, this can be automated in VS2010. This method will mean that the list removal is only on your enviroment and then there is no danger of deleting lists on a live environment.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.