0

I have an Visual Studio 2010 empty sharepoint solution project. Solutions consist of several custom lists and workflows attached to that lists. The solution always changes, so it means I'm redeploying the solution very often. After deploying it deletes all of the content from the existed lists and recreates that lists again. Now I'm considering the ways how to solve the problem of disappearing of the data, are there effective ways?

p.s. I cannot use lists created in UI, because I need custom defined lists.

1 Answer 1

1

Are you changing the list columns/content types within deployments? If not, then you could change your solution so that it only deploys list definitions and then write a feature receiver to instantiate the list from the definition.

In a similar situation, I used code like the below (SP2013 but should work in 2010)

  if (oWeb.Lists.TryGetList("ListName") == null)
            {
                SPListTemplate listTemplate = oWeb.ListTemplates["ListTemplateName"];
                Guid listGuid = oWeb.Lists.Add("ListName", "List Description", listTemplate);

            }

within a feature receiver to accomplish this.

Of course, if your list definition is changing, things are more complicated. In the past, I've done hacky things like copy all the data out via DataSheet view and then paste it back in after the list is recreated. I would recommend using PowerShell scripts to migrate the existing list to your new structure instead - that's what I generally do in production rather than deal with redeploying list templates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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