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

If I generate .cs file using SPMetal for my site and then use it in Visual Studio to develop web part using Linq. And later on I create a new list in my site, will I need to generate .cs file again?

share|improve this question
up vote 2 down vote accepted

Short answer is "Unfortunately, yes, you have to generete .cs files again".

After changing the list structure you need to regenerate cs files or create custom mapping.

Piece of code from Joerg Krause "SharePoint 2010 as a Developer Platform" (by the way, it is a very nice book and I advice you to buy and read it if you haven't read it yet):

public partial class Book: ICustomMapping
    [CustomMapping(Columns=new String[]{"ISBN","UPCA"})]
    public void MapFrom(object listItem)
       SPListItem item=(SPListItem) listItem;

    public void MapTo(object listItem)
       SPListItem item=(SPListItem) listItem;

    //New property declaratin go here
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.