Search code examples
codefluent

How to define a reflexive assocation in CodeFluent


What is the proper way to define a reflexive assocation in code fluent. Given this example, the design shows up correctly, but the generation would struggle with enclosed error message:

Error CF0036: Type for property 'OldEntityA' of entity 'Namespace.EntityA' must be a project entity if 'relationPropertyName' attribute is specified.

<cf:entity name="EntityA" namespace="Namespace" categoryPath="/Category">
<cf:property name="Id" key="true" collectionKey="false" />
<cf:property name="Url" collectionKey="false" />
<cf:property name="OldEntityA" typeName="Namespace.EntityA" relationPropertyName="Unspecified" collectionKey="false" />

Thanks in advance,


Solution

  • You must remove the relationPropertyName attribute or set its value to a valid property name:

    <cf:entity name="Category">
      <cf:property name="Id" key="true" />
      <cf:property name="Name" />
      <cf:property name="Parent" typeName="{0}.Category" relationPropertyName="Children" />
      <cf:property name="Children" typeName="{0}.CategoryCollection" relationPropertyName="Parent" />
    </cf:entity>