SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a feature which on activation has to create a list called Scanners. Only one column from the list (Title) is actually used in my app. The list needs to be pre-populated with some values. To fill in the values I used the ListInstance's Elements.xml, so now it looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
  <ListInstance Title="Scanners"                
          <Field Name="Title">DevScanner</Field>
          <Field Name="Title">ProdScanner</Field>
          <Field Name="Title">TestScanner</Field>

The list instance is created at the Site(Web) level. On Feature activation, the list instance should be created only if the site doesn't already contain a list with the same name (Scanners). The current behavior does this, but with one problem. On each activation, the data gets added again to the existing list, so I end up with lots of duplicate rows. How can this be prevented?

The client's specs don't allow me to delete the list on feature deactivation. I tried fiddling with the Deployment Conflict Resolution setting, with no success.

share|improve this question
up vote 3 down vote accepted

If your feature can be activated/deactivated multiple times then you should not use the <data> elemente to populate elements into the list instance. As you get the duplicate item effect that you're experiencing and there is no way to prevent that.
The Deployment Conflict Resolution setting is only used by Visual Studio when deploying to your local environment (and the way it solves the problem is by deleting the list instance). I'm not 100% agreeing with MS that this is good idea as it hides a lot of problems which will occur in test/production from the dev. environment.

The solution for your problem is to pre-populated rows into the list instance without duplication. You should pre-populate using code in a FeatureReceiver where you can check if the list is empty before adding the rows.

share|improve this answer

You can also add the following line for each <row>:

<Field Name="ID">1</Field>

For example:

      <Field Name="Title">DevScanner</Field>
      <Field Name="ID">1</Field>

As the ID is still the same it won't add a new record, so it prevents duplicate rows.

share|improve this answer
This worked well for me. Thanks! – Roel Hans Bethlehem May 16 '13 at 7:58
Worked for me too, thanks! – KGahbiche Jun 6 at 12:07

This could solve the duplicates:

share|improve this answer
wow, nice find, thanks – pax162 Apr 19 '12 at 8:27

Your Answer


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.