0

我需要知道是否可以在多对多关系上添加属性,或者我应该去添加一个具有关系的实体吗?在额外实体的情况下,如何让两个引用的表参与键(获取两个表的复合键)?

我关注了这篇文章,但还不够深入:http: //blog.codefluententities.com/2012/06/14/many-to-many-relationships-with-codefluent-entities/

提前致谢,

4

1 回答 1

1

您必须创建一个具有关系的实体。这个新实体有一个复合键,所以你还必须设置setType="List"

<cf:entity name="Student">
  <cf:property name="Id" key="true" />
  <cf:property name="Name" />
  <cf:property name="Enrollments" typeName="{0}.EnrollmentCollection" relationPropertyName="Student" />
</cf:entity>

<cf:entity name="Course">
  <cf:property name="Id" key="true" />
  <cf:property name="Name" />
  <cf:property name="Enrollments" typeName="{0}.EnrollmentCollection" relationPropertyName="Course" />
</cf:entity>

<cf:entity name="Enrollment" setType="List">
  <cf:property name="Course" key="true" typeName="{0}.Course" relationPropertyName="Enrollments" />
  <cf:property name="Student" key="true" typeName="{0}.Student" relationPropertyName="Enrollments" />
  <cf:property name="Prop1" />
  <cf:property name="Prop2" />
</cf:entity>
于 2016-02-19T09:13:54.863 回答