我有一张带有 PK 的 Authors 表AuthorID
。
然后我有一个名为 AuthoritativeAuthors 的表,带有 PK AuthorID
。
AuthoritativeAuthor.AuthorID 是指向 Authors.AuthorID 的外键。Authors 中的 AuthorID 可能会或可能不会出现在 AuthoritativeAuthors 中。
这是我得到的错误
Error 3021: Problem in mapping fragments starting at line 4365:Each of the following columns in table AuthoritativeAuthors is mapped to multiple conceptual side properties:
AuthoritativeAuthors.AuthorID is mapped to <FK_AuthoritativeAuthors_Authors.AuthoritativeAuthor.AuthorID, FK_AuthoritativeAuthors_Authors.Author.AuthorID>
这是 edmx 中似乎相关的所有代码。
存储模型
<EntityType Name="Authors">
<Key>
<PropertyRef Name="AuthorID" />
</Key>
<Property Name="AuthorID" Type="int" Nullable="false" />
<Property Name="Name" Type="nvarchar" MaxLength="254" />
</EntityType>
<EntityType Name="AuthoritativeAuthors">
<Key>
<PropertyRef Name="AuthorID" />
</Key>
<Property Name="AuthoritativeAuthorID" Type="int" Nullable="false" />
<Property Name="AuthorID" Type="int" Nullable="false" />
</EntityType>
<Association Name="FK_AuthoritativeAuthors_Authors">
<End Role="AuthoritativeAuthor" Type="WCDBModel.Store.AuthoritativeAuthors" Multiplicity="0..1" />
<End Role="Author" Type="WCDBModel.Store.Authors" Multiplicity="1" />
<ReferentialConstraint>
<Principal Role="Author">
<PropertyRef Name="AuthorID" />
</Principal>
<Dependent Role="AuthoritativeAuthor">
<PropertyRef Name="AuthorID" />
</Dependent>
</ReferentialConstraint>
</Association>
概念模型
<EntitySet Name="AuthorSet" EntityType="WCDBModel.Author" />
<EntitySet Name="AuthoritativeAuthorSet" EntityType="WCDBModel.AuthoritativeAuthor" />
<AssociationSet Name="FK_AuthoritativeAuthors_Authors" Association="WCDBModel.FK_AuthoritativeAuthors_Authors">
<End Role="Author" EntitySet="AuthorSet" />
<End Role="AuthoritativeAuthor" EntitySet="AuthoritativeAuthorSet" />
</AssociationSet>
<EntityType Name="Author">
<Key>
<PropertyRef Name="AuthorID" />
</Key>
<Property Name="AuthorID" Type="Int32" Nullable="false" />
<Property Name="Name" Type="String" Nullable="true" />
<NavigationProperty Name="AuthoritativeAuthors" Relationship="WCDBModel.FK_AuthoritativeAuthors_Authors" FromRole="Author" ToRole="AuthoritativeAuthor" />
</EntityType>
<Association Name="FK_AuthoritativeAuthors_Authors">
<End Type="WCDBModel.Author" Role="Author" Multiplicity="1" />
<End Type="WCDBModel.AuthoritativeAuthor" Role="AuthoritativeAuthor" Multiplicity="0..1" />
</Association>
<EntityType Name="AuthoritativeAuthor">
<Key>
<PropertyRef Name="AuthorID" />
</Key>
<Property Type="Int32" Name="AuthorID" Nullable="false" />
<Property Type="Int32" Name="AuthoritativeAuthorID" Nullable="false" />
<NavigationProperty Name="Author" Relationship="WCDBModel.FK_AuthoritativeAuthors_Authors" FromRole="AuthoritativeAuthor" ToRole="Author" />
</EntityType>
映射
<EntitySetMapping Name="AuthorSet">
<EntityTypeMapping TypeName="IsTypeOf(WCDBModel.Author)">
<MappingFragment StoreEntitySet="Authors">
<ScalarProperty Name="Name" ColumnName="Name" />
<ScalarProperty Name="AuthorID" ColumnName="AuthorID" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="AuthoritativeAuthorSet">
<EntityTypeMapping TypeName="IsTypeOf(WCDBModel.AuthoritativeAuthor)">
<MappingFragment StoreEntitySet="AuthoritativeAuthors">
<ScalarProperty Name="AuthoritativeAuthorID" ColumnName="AuthoritativeAuthorID"/>
<ScalarProperty Name="AuthorID" ColumnName="AuthorID" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<AssociationSetMapping Name="FK_AuthoritativeAuthors_Authors" TypeName="WCDBModel.FK_AuthoritativeAuthors_Authors" StoreEntitySet="AuthoritativeAuthors">
<EndProperty Name="AuthoritativeAuthor">
<ScalarProperty Name="AuthorID" ColumnName="AuthorID" />
</EndProperty>
<EndProperty Name="Author">
<ScalarProperty Name="AuthorID" ColumnName="AuthorID" />
</EndProperty>
<Condition ColumnName="AuthorID" IsNull="false" />
</AssociationSetMapping>
任何帮助查找此错误的原因将不胜感激。