この質問に 加えて、複数の抽象継承 と VS.2008 sp1 .net 3.5 c#を使用する Entity Framework TPH
組織と学校を追加することにしました。Organization(abstract) は Party を継承し、School(concrete) は Organization を継承します。
エラーが発生します:
Error 1 Error 3034: Problem in Mapping Fragments starting at lines 73, 93: Two entities with different keys are mapped to the same row. Ensure these two mapping fragments do not map two groups of entities with different keys to the same group of rows.
C:\Users\xxx\Documents\Visual Studio 2008\Projects\TEST\TEST\Model1.edmx 74 29 TEST
私は EF での旅行中に 3034 エラーをたくさん見てきました。ただし、通常はナビゲーション プロパティに関連しています。継承でこのようなエラーは見たことがありません。
ここに私のedmx xmlがあります:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0"
xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="test_1Model.Store" Alias="Self"
Provider="System.Data.SqlClient" ProviderManifestToken="2005"
xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator"
xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">
<EntityContainer Name="test_1ModelStoreContainer">
<EntitySet Name="Student" EntityType="test_1Model.Store.Student"
store:Type="Tables" Schema="dbo" />
</EntityContainer>
<EntityType Name="Student">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="int" Nullable="false"
StoreGeneratedPattern="Identity" />
<Property Name="PartyInfo" Type="varchar(max)" Nullable="false" />
<Property Name="PersonInfo" Type="varchar(max)" Nullable="true" />
<Property Name="StudInfo" Type="varchar(max)" Nullable="true" />
<Property Name="OrgInfo" Type="varchar(max)" Nullable="true" />
<Property Name="SchoolInfo" Type="varchar(max)" Nullable="true" />
<Property Name="TypeOfParty" Type="varchar(max)" Nullable="false" />
</EntityType>
</Schema>
</edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="test_1Model" Alias="Self"
xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
<EntityContainer Name="test_Entities">
<EntitySet Name="PartySet" EntityType="test_1Model.Party" />
</EntityContainer>
<EntityType Name="Party" Abstract="true">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Int32" Nullable="false" />
<Property Name="PartyInfo" Type="String" Nullable="false"
MaxLength="Max" Unicode="false" FixedLength="false" />
</EntityType>
<EntityType Name="Person" BaseType="test_1Model.Party" Abstract="true" >
<Property Name="PersonInfo" Type="String" Nullable="false" />
</EntityType>
<EntityType Name="Student" BaseType="test_1Model.Person" >
<Property Name="StudInfo" Type="String" Nullable="false" />
</EntityType>
<EntityType Name="Organization" BaseType="test_1Model.Party" Abstract="true" >
<Property Name="OrgInfo" Type="String" Nullable="false" />
</EntityType>
<EntityType Name="School" BaseType="test_1Model.Organization" >
<Property Name="SchoolInfo" Type="String" Nullable="false" />
</EntityType>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S"
xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS">
<EntityContainerMapping
StorageEntityContainer="test_1ModelStoreContainer"
CdmEntityContainer="test_Entities">
<EntitySetMapping Name="PartySet">
<EntityTypeMapping TypeName="IsTypeOf(test_1Model.Party)">
<MappingFragment StoreEntitySet="Student">
<ScalarProperty Name="PartyInfo" ColumnName="PartyInfo" />
<ScalarProperty Name="Id" ColumnName="Id" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(test_1Model.Person)">
<MappingFragment StoreEntitySet="Student">
<ScalarProperty Name="Id" ColumnName="Id" />
<ScalarProperty Name="PersonInfo" ColumnName="PersonInfo" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="test_1Model.Student">
<MappingFragment StoreEntitySet="Student">
<ScalarProperty Name="Id" ColumnName="Id" />
<ScalarProperty Name="StudInfo" ColumnName="StudInfo" />
<ScalarProperty Name="PersonInfo" ColumnName="PersonInfo" />
<ScalarProperty Name="PartyInfo" ColumnName="PartyInfo" />
<Condition ColumnName="TypeOfParty" Value="STUDENT" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(test_1Model.Organization)">
<MappingFragment StoreEntitySet="Student">
<ScalarProperty Name="Id" ColumnName="Id" />
<ScalarProperty Name="OrgInfo" ColumnName="OrgInfo" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="test_1Model.School">
<MappingFragment StoreEntitySet="Student">
<ScalarProperty Name="Id" ColumnName="Id" />
<ScalarProperty Name="OrgInfo" ColumnName="OrgInfo" />
<ScalarProperty Name="PartyInfo" ColumnName="PartyInfo" />
<ScalarProperty Name="SchoolInfo" ColumnName="SchoolInfo" />
<Condition ColumnName="TypeOfParty" Value="SCHOOL" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
</edmx:Runtime>
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:Connection>
<DesignerInfoPropertySet>
<DesignerProperty Name="MetadataArtifactProcessing"
Value="EmbedInOutputAssembly" />
</DesignerInfoPropertySet>
</edmx:Connection>
<edmx:Options>
<DesignerInfoPropertySet>
<DesignerProperty Name="ValidateOnBuild" Value="true" />
</DesignerInfoPropertySet>
</edmx:Options>
<!-- Diagram content (shape and connector positions) -->
<edmx:Diagrams>
<Diagram Name="SqlServer_Model" >
<EntityTypeShape EntityType="test_1Model.Party" Width="1.5" PointX="1.25" PointY="3.25" Height="1.4033821614583326" />
<InheritanceConnector EntityType="test_1Model.Person" ManuallyRouted="false">
<ConnectorPoint PointX="2" PointY="4.6533821614583326" />
<ConnectorPoint PointX="2" PointY="5.75" />
</InheritanceConnector>
<EntityTypeShape EntityType="test_1Model.Organization" Width="1.5" PointX="3.875" PointY="5.625" Height="1.2110807291666665" />
<InheritanceConnector EntityType="test_1Model.Organization">
<ConnectorPoint PointX="2.75" PointY="3.9516910807291663" />
<ConnectorPoint PointX="4.625" PointY="3.9516910807291663" />
<ConnectorPoint PointX="4.625" PointY="5.625" />
</InheritanceConnector>
<EntityTypeShape EntityType="test_1Model.School" Width="1.5" PointX="3.875" PointY="7.875" Height="1.2110807291666657" />
<InheritanceConnector EntityType="test_1Model.School">
<ConnectorPoint PointX="4.625" PointY="6.8360807291666665" />
<ConnectorPoint PointX="4.625" PointY="7.875" />
</InheritanceConnector>
</Diagram>
</edmx:Diagrams>
</edmx:Designer>
</edmx:Edmx>