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'm not sure if I have found a bug here or if I'm doing something wrong.

I have a list which I provision using a SPI in Visual Studio, in the List Instance XML I provision some default list items using the Data Element (see code snippet below):

      <Field Name="Title">myItem</Field>
      <Field Name="Key">myItem</Field>
      <Field Name="Value">myValue</Field>

The list items above are of a particular Content Type which has been added to the list. I then generated the entity classes for my list and content type by running SPMetal. In a web part I have the following code which queries the list using Linq to SharePoint -

 DataContext context = new DataContext(SPContext.Current.Site.RootWeb.Url);

        // Get the config items
        EntityList<ConfigItem> configItems = context.GetList<PhoneBookConfigItem>("Config List");

        // Query for the config item
        var items = from configItem in configItems
                        where configItem.Key == "myItem"
                  select configItem;

        string value = item.Value;

The problem is that the EntityList count is always empty. If I got to the list and edit the item and re-query it seems to pickup the one item. If I add new items to the list via the UI I can query successfully for those items.

It's almost like they have not been written to the database correctly when provisioned through the List Instance. Has anyone seen this issue before? it's quite frustrating as you can imagine!



share|improve this question

"PhoneBookConfigItem" is the default contenttype of your list? if not, your listinstanse xml missing the ContentType Field

     <Field Name="ContentType">PhoneBookConfigItem</Field>
     <Field Name="Title">myItem</Field>
     <Field Name="Key">myItem</Field>
     <Field Name="Value">myValue</Field>
share|improve this answer

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.