1

PK を持つ Authors のテーブルがありますAuthorID

次に、 PK を持つ AuthoritativeAuthors というテーブルがあります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>

このエラーの原因を見つけるための支援をいただければ幸いです。

4

1 に答える 1

0

AuthoritativeAuthor テーブルにダミーの主キーを作成しましたが、これは外部キーでもありませんでした。

于 2013-03-04T18:33:43.500 に答える