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 defined site definition with two content types and two list definitions. I have lookup site column

<Field ID="{4318c52f-11c6-129a-b832-5ab22450b17c}"
         Type="Lookup"
         List="Lists/Questions"
         ShowField="ID"
         Name="QuestionID"
         DisplayName="QuestionID"
         StaticName="QuestionID"
         Group="KnowledgeBase"
         DisplaceOnUpgrade="TRUE"
         Required="TRUE"/>

Than I use this field in Content Type

<ContentType ID="0x0100c2644b24e4ec4626be41a720171942a6"
               Name="CTAnswer"
               Group="Answer Content Type"
               Description="Answer Conent Type"
               Inherits="TRUE"
               Version="0">
    <FieldRefs>
      <FieldRef ID="{fa542e0f-0a70-4ab9-b92c-0177e6ddd247}" Name="AnswerContent"  
                DisplayName="Content"/>
      <FieldRef ID="{1318c52f-11c6-4b3a-b802-d0b22450b1bc}" Name="AnswerRank"   
                DisplayName="Rank"/>
      <FieldRef ID="{4318c52f-11c6-129a-b832-5ab22450b17c}" Name="QuestionID" 
                DisplayName="QuestionID"/>
    </FieldRefs>
  </ContentType>

and after that I create List Definition based on this content type. Everything is ok, but SPMetal generates my lookups as System.Nullable, and not as EntityRef. What is wrong? Where am I mistaken?

share|improve this question
add comment

1 Answer 1

Both source and target list must be included in the generated classes, and fields of a type understood by SPMetal (no custom types).

If you really can't get them to generate, you can code them yourself in partial classes.

share|improve this answer
1  
the more I use SPMetal, the more I think this was an error. This tools is very unpredictable, and so unreliable. And we quickly reach limits of the generated code. –  Steve B Jul 2 '12 at 21:48
    
We converted everything back to caml after unpredictable errors. It caused a lot of pain. –  billfredtom Jan 29 '13 at 6:04
add comment

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.