0

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?

1 Answer 1

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.

2
  • 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, 2012 at 21:48
  • We converted everything back to caml after unpredictable errors. It caused a lot of pain. Jan 29, 2013 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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