- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用 .NET Framework 3.5 SP1 在 Visual Studio 2008 SP1 中使用 ADO Entity Framework 编写数据访问库。我正在尝试在两个都派生自抽象类型的实体之间创建关联。我使用 Table Per Hierarchy 表示两个实体继承层次结构(TPH) 这意味着只有两个表 - 每个实体继承层次结构一个。
注意 您可以使用 Table Per Type (TPT) 来避免这个问题,但它有它自己的缺点。参见 here和 here在继承持久性模型之间进行选择时了解更多详细信息。
这是实体模型的设计器 View 的屏幕截图:
这是数据库架构的屏幕截图:
当您在 ADO Entity Framework Designer 中创建使用 Visual Studio 2008 SP1 和 .NET Framework 3.5 SP1 使用 TPH 建模的派生类型之间的关联时,您可能会收到以下消息“错误 3034:映射了具有不同键的两个实体到同一行。确保这两个映射片段不会将具有重叠键的两组实体映射到同一组行。”
基于我所拥有的read online ,为了解决这个问题,你必须像这样在外键上的关联中添加一个条件:
<Condition ColumnName="Endpoint1" IsNull="false" />
这是对 PersonPersonToPerson1 关联进行此编辑的屏幕截图:
当我如上所述创建实体模型并按照上述假设将条件添加到 AssociationMappings 时,我在构建/验证模型时收到“错误 3023”。
Error 1 Error 3023: Problem in Mapping Fragments starting at lines 146, 153, 159, 186, 195, 204, 213: Column Link.Endpoint1 has no default value and is not nullable. A column value is required to store entity data.
An Entity with Key (PK) will not round-trip when:
((PK is NOT in 'LinkSet' EntitySet OR PK does NOT play Role 'PersonToPerson' in AssociationSet 'PersonPersonToPerson1') AND (PK is in 'LinkSet' EntitySet OR PK plays Role 'PersonToPerson' in AssociationSet 'PersonPersonToPerson1' OR PK plays Role 'PersonToPerson' in AssociationSet 'PersonPersonToPerson'))
C:\Documents and Settings\Demo\My Documents\Visual Studio 2008\Projects\GraphExample2.BusinessEntities\GraphExample2.BusinessEntities\GraphModel.edmx 147 15 GraphExample2.BusinessEntities
Entity Framework 在上述场景中遇到的问题是有两个属性被映射到相同的外键。例如,Endpoint1 的列和外键映射到 PersonToLocation 派生类型中的 Person 属性,并映射到 PersonToPerson 派生类型中的 Leader 属性。
我不明白为什么这是个问题。由于 Leader/Follower 属性仅在 PersonToPerson 派生类型中——而不是任何其他派生类型或基类型——并且 Person/Location 属性也是如此,为什么 TypeDiscriminator 字段不足以让 EF 确定哪个设置给定行属于?
在我看来,如果您正在处理 TypeDiscriminator = 1 的对象,则将 Endpoint1 放在 Leader 中,将 Endpoint2 放在 Follower 中。同样,如果您正在处理 TypeDiscriminator = 2 的对象,则将 Endpoint1 放在 Person 中,将 Endpoint2 放在 Location 中。
如何解决错误 3023 以允许这些关联发生?
或
如何在我上面描述的 ADO Entity Framework 中创建关联类型?
SQL:
USE [GraphExample2]
GO
/****** Object: Table [dbo].[Node] Script Date: 02/17/2009 14:36:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Node](
[NodeID] [int] NOT NULL,
[NodeTypeDiscriminator] [int] NOT NULL,
[Name] [varchar](255) NOT NULL,
[Description] [varchar](1023) NULL,
CONSTRAINT [PK_Node] PRIMARY KEY CLUSTERED
(
[NodeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Link] Script Date: 02/17/2009 14:36:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Link](
[LinkID] [int] NOT NULL,
[LinkTypeDiscriminator] [int] NOT NULL,
[Endpoint1] [int] NOT NULL,
[Endpoint2] [int] NOT NULL,
[Name] [varchar](255) NULL,
[Description] [varchar](1023) NULL,
CONSTRAINT [PK_Link] PRIMARY KEY CLUSTERED
(
[LinkID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: ForeignKey [FK_Link_Node_Endpoint1] Script Date: 02/17/2009 14:36:12 ******/
ALTER TABLE [dbo].[Link] WITH CHECK ADD CONSTRAINT [FK_Link_Node_Endpoint1] FOREIGN KEY([Endpoint1])
REFERENCES [dbo].[Node] ([NodeID])
GO
ALTER TABLE [dbo].[Link] CHECK CONSTRAINT [FK_Link_Node_Endpoint1]
GO
/****** Object: ForeignKey [FK_Link_Node_Endpoint2] Script Date: 02/17/2009 14:36:12 ******/
ALTER TABLE [dbo].[Link] WITH CHECK ADD CONSTRAINT [FK_Link_Node_Endpoint2] FOREIGN KEY([Endpoint2])
REFERENCES [dbo].[Node] ([NodeID])
GO
ALTER TABLE [dbo].[Link] CHECK CONSTRAINT [FK_Link_Node_Endpoint2]
GO
EDMX:
<?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="GraphModel.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="GraphModelStoreContainer">
<EntitySet Name="Link" EntityType="GraphModel.Store.Link" store:Type="Tables" Schema="dbo" />
<EntitySet Name="Node" EntityType="GraphModel.Store.Node" store:Type="Tables" Schema="dbo" />
<AssociationSet Name="FK_Link_Node_Endpoint1" Association="GraphModel.Store.FK_Link_Node_Endpoint1">
<End Role="Node" EntitySet="Node" />
<End Role="Link" EntitySet="Link" />
</AssociationSet>
<AssociationSet Name="FK_Link_Node_Endpoint2" Association="GraphModel.Store.FK_Link_Node_Endpoint2">
<End Role="Node" EntitySet="Node" />
<End Role="Link" EntitySet="Link" />
</AssociationSet>
</EntityContainer>
<EntityType Name="Link">
<Key>
<PropertyRef Name="LinkID" />
</Key>
<Property Name="LinkID" Type="int" Nullable="false" />
<Property Name="LinkTypeDiscriminator" Type="int" Nullable="false" />
<Property Name="Endpoint1" Type="int" Nullable="false" />
<Property Name="Endpoint2" Type="int" Nullable="false" />
<Property Name="Name" Type="varchar" MaxLength="255" />
<Property Name="Description" Type="varchar" MaxLength="1023" />
</EntityType>
<EntityType Name="Node">
<Key>
<PropertyRef Name="NodeID" />
</Key>
<Property Name="NodeID" Type="int" Nullable="false" />
<Property Name="NodeTypeDiscriminator" Type="int" Nullable="false" />
<Property Name="Name" Type="varchar" Nullable="false" MaxLength="255" />
<Property Name="Description" Type="varchar" MaxLength="1023" />
</EntityType>
<Association Name="FK_Link_Node_Endpoint1">
<End Role="Node" Type="GraphModel.Store.Node" Multiplicity="1" />
<End Role="Link" Type="GraphModel.Store.Link" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Node">
<PropertyRef Name="NodeID" />
</Principal>
<Dependent Role="Link">
<PropertyRef Name="Endpoint1" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Link_Node_Endpoint2">
<End Role="Node" Type="GraphModel.Store.Node" Multiplicity="1" />
<End Role="Link" Type="GraphModel.Store.Link" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Node">
<PropertyRef Name="NodeID" />
</Principal>
<Dependent Role="Link">
<PropertyRef Name="Endpoint2" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema>
</edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema xmlns="http://schemas.microsoft.com/ado/2006/04/edm" Namespace="GraphModel" Alias="Self">
<EntityContainer Name="GraphModelContainer" >
<EntitySet Name="NodeSet" EntityType="GraphModel.Node" />
<EntitySet Name="LinkSet" EntityType="GraphModel.Link" />
<AssociationSet Name="PersonPersonToPerson" Association="GraphModel.PersonPersonToPerson">
<End Role="Person" EntitySet="NodeSet" />
<End Role="PersonToPerson" EntitySet="LinkSet" />
</AssociationSet>
<AssociationSet Name="PersonPersonToPerson1" Association="GraphModel.PersonPersonToPerson1">
<End Role="Person" EntitySet="NodeSet" />
<End Role="PersonToPerson" EntitySet="LinkSet" />
</AssociationSet>
<AssociationSet Name="Person_PersonToLocation" Association="GraphModel.Person_PersonToLocation">
<End Role="Person" EntitySet="NodeSet" />
<End Role="PersonToLocation" EntitySet="LinkSet" />
</AssociationSet>
<AssociationSet Name="Location_PersonToLocation" Association="GraphModel.Location_PersonToLocation">
<End Role="Location" EntitySet="NodeSet" />
<End Role="PersonToLocation" EntitySet="LinkSet" />
</AssociationSet>
</EntityContainer>
<EntityType Name="Node" Abstract="true">
<Key>
<PropertyRef Name="NodeId" />
</Key>
<Property Name="NodeId" Type="Int32" Nullable="false" />
<Property Name="Name" Type="String" Nullable="false" />
<Property Name="Description" Type="String" Nullable="true" />
</EntityType>
<EntityType Name="Person" BaseType="GraphModel.Node" >
<NavigationProperty Name="Leaders" Relationship="GraphModel.PersonPersonToPerson" FromRole="Person" ToRole="PersonToPerson" />
<NavigationProperty Name="Followers" Relationship="GraphModel.PersonPersonToPerson1" FromRole="Person" ToRole="PersonToPerson" />
<NavigationProperty Name="Locations" Relationship="GraphModel.Person_PersonToLocation" FromRole="Person" ToRole="PersonToLocation" />
</EntityType>
<EntityType Name="Location" BaseType="GraphModel.Node" >
<NavigationProperty Name="Visitors" Relationship="GraphModel.Location_PersonToLocation" FromRole="Location" ToRole="PersonToLocation" />
</EntityType>
<EntityType Name="Link" Abstract="true">
<Key>
<PropertyRef Name="LinkId" />
</Key>
<Property Name="LinkId" Type="Int32" Nullable="false" />
<Property Name="Name" Type="String" Nullable="true" />
<Property Name="Description" Type="String" Nullable="true" />
</EntityType>
<EntityType Name="PersonToPerson" BaseType="GraphModel.Link" >
<NavigationProperty Name="Leader" Relationship="GraphModel.PersonPersonToPerson" FromRole="PersonToPerson" ToRole="Person" />
<NavigationProperty Name="Follower" Relationship="GraphModel.PersonPersonToPerson1" FromRole="PersonToPerson" ToRole="Person" />
</EntityType>
<EntityType Name="PersonToLocation" BaseType="GraphModel.Link" >
<NavigationProperty Name="Person" Relationship="GraphModel.Person_PersonToLocation" FromRole="PersonToLocation" ToRole="Person" />
<NavigationProperty Name="Location" Relationship="GraphModel.Location_PersonToLocation" FromRole="PersonToLocation" ToRole="Location" />
</EntityType>
<Association Name="PersonPersonToPerson">
<End Type="GraphModel.Person" Role="Person" Multiplicity="1" />
<End Type="GraphModel.PersonToPerson" Role="PersonToPerson" Multiplicity="*" />
</Association>
<Association Name="PersonPersonToPerson1">
<End Type="GraphModel.Person" Role="Person" Multiplicity="1" />
<End Type="GraphModel.PersonToPerson" Role="PersonToPerson" Multiplicity="*" />
</Association>
<Association Name="Person_PersonToLocation">
<End Type="GraphModel.Person" Role="Person" Multiplicity="1" />
<End Type="GraphModel.PersonToLocation" Role="PersonToLocation" Multiplicity="*" />
</Association>
<Association Name="Location_PersonToLocation">
<End Type="GraphModel.Location" Role="Location" Multiplicity="1" />
<End Type="GraphModel.PersonToLocation" Role="PersonToLocation" Multiplicity="*" />
</Association>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS" Space="C-S">
<Alias Key="Model" Value="GraphModel" />
<Alias Key="Target" Value="GraphModel.Store" />
<EntityContainerMapping CdmEntityContainer="GraphModelContainer" StorageEntityContainer="GraphModelStoreContainer">
<EntitySetMapping Name="LinkSet">
<EntityTypeMapping TypeName="IsTypeOf(GraphModel.Link)">
<MappingFragment StoreEntitySet="Link">
<ScalarProperty Name="Description" ColumnName="Description" />
<ScalarProperty Name="Name" ColumnName="Name" />
<ScalarProperty Name="LinkId" ColumnName="LinkID" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(GraphModel.PersonToPerson)">
<MappingFragment StoreEntitySet="Link" >
<ScalarProperty Name="LinkId" ColumnName="LinkID" />
<Condition ColumnName="LinkTypeDiscriminator" Value="1" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(GraphModel.PersonToLocation)">
<MappingFragment StoreEntitySet="Link" >
<ScalarProperty Name="LinkId" ColumnName="LinkID" />
<Condition ColumnName="LinkTypeDiscriminator" Value="2" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="NodeSet">
<EntityTypeMapping TypeName="IsTypeOf(GraphModel.Node)">
<MappingFragment StoreEntitySet="Node">
<ScalarProperty Name="Description" ColumnName="Description" />
<ScalarProperty Name="Name" ColumnName="Name" />
<ScalarProperty Name="NodeId" ColumnName="NodeID" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(GraphModel.Person)">
<MappingFragment StoreEntitySet="Node" >
<ScalarProperty Name="NodeId" ColumnName="NodeID" />
<Condition ColumnName="NodeTypeDiscriminator" Value="1" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(GraphModel.Location)">
<MappingFragment StoreEntitySet="Node" >
<ScalarProperty Name="NodeId" ColumnName="NodeID" />
<Condition ColumnName="NodeTypeDiscriminator" Value="2" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<AssociationSetMapping Name="PersonPersonToPerson1" TypeName="GraphModel.PersonPersonToPerson1" StoreEntitySet="Link">
<EndProperty Name="Person">
<ScalarProperty Name="NodeId" ColumnName="Endpoint1" />
</EndProperty>
<EndProperty Name="PersonToPerson">
<ScalarProperty Name="LinkId" ColumnName="LinkID" />
</EndProperty>
<Condition ColumnName="Endpoint1" IsNull="false" />
</AssociationSetMapping>
<AssociationSetMapping Name="PersonPersonToPerson" TypeName="GraphModel.PersonPersonToPerson" StoreEntitySet="Link">
<EndProperty Name="Person">
<ScalarProperty Name="NodeId" ColumnName="Endpoint2" />
</EndProperty>
<EndProperty Name="PersonToPerson">
<ScalarProperty Name="LinkId" ColumnName="LinkID" />
</EndProperty>
<Condition ColumnName="Endpoint2" IsNull="false" />
</AssociationSetMapping>
<AssociationSetMapping Name="Person_PersonToLocation" TypeName="GraphModel.Person_PersonToLocation" StoreEntitySet="Link">
<EndProperty Name="Person">
<ScalarProperty Name="NodeId" ColumnName="Endpoint1" />
</EndProperty>
<EndProperty Name="PersonToLocation">
<ScalarProperty Name="LinkId" ColumnName="LinkID" />
</EndProperty>
<Condition ColumnName="Endpoint1" IsNull="false" />
</AssociationSetMapping>
<AssociationSetMapping Name="Location_PersonToLocation" TypeName="GraphModel.Location_PersonToLocation" StoreEntitySet="Link">
<EndProperty Name="Location">
<ScalarProperty Name="NodeId" ColumnName="Endpoint2" />
</EndProperty>
<EndProperty Name="PersonToLocation">
<ScalarProperty Name="LinkId" ColumnName="LinkID" />
</EndProperty>
<Condition ColumnName="Endpoint2" IsNull="false" />
</AssociationSetMapping>
</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="GraphModel" ZoomLevel="114" >
<EntityTypeShape EntityType="GraphModel.Node" Width="1.5" PointX="5.875" PointY="1.375" Height="1.427958984375" />
<EntityTypeShape EntityType="GraphModel.Person" Width="1.5" PointX="5.875" PointY="3.25" Height="1.4279589843749996" />
<EntityTypeShape EntityType="GraphModel.Location" Width="1.5" PointX="7.75" PointY="4.625" Height="1.0992643229166665" />
<InheritanceConnector EntityType="GraphModel.Location">
<ConnectorPoint PointX="7.375" PointY="2.0889794921875" />
<ConnectorPoint PointX="8.5" PointY="2.0889794921875" />
<ConnectorPoint PointX="8.5" PointY="4.625" />
</InheritanceConnector>
<EntityTypeShape EntityType="GraphModel.Link" Width="1.5" PointX="2.875" PointY="1.375" Height="1.427958984375" />
<EntityTypeShape EntityType="GraphModel.PersonToPerson" Width="1.75" PointX="2.625" PointY="3.125" Height="0.9349169921875" />
<InheritanceConnector EntityType="GraphModel.PersonToPerson">
<ConnectorPoint PointX="3.625" PointY="2.802958984375" />
<ConnectorPoint PointX="3.625" PointY="3.125" />
</InheritanceConnector>
<InheritanceConnector EntityType="GraphModel.Person">
<ConnectorPoint PointX="6.625" PointY="2.802958984375" />
<ConnectorPoint PointX="6.625" PointY="3.25" />
</InheritanceConnector>
<EntityTypeShape EntityType="GraphModel.PersonToLocation" Width="1.875" PointX="0.75" PointY="4.625" Height="1.2636116536458326" />
<InheritanceConnector EntityType="GraphModel.PersonToLocation">
<ConnectorPoint PointX="2.875" PointY="2.0889794921875" />
<ConnectorPoint PointX="1.65625" PointY="2.0889794921875" />
<ConnectorPoint PointX="1.65625" PointY="4.625" />
</InheritanceConnector>
<AssociationConnector Association="GraphModel.PersonPersonToPerson">
<ConnectorPoint PointX="5.875" PointY="3.8193058268229163" />
<ConnectorPoint PointX="4.375" PointY="3.8193058268229163" />
</AssociationConnector>
<AssociationConnector Association="GraphModel.PersonPersonToPerson1">
<ConnectorPoint PointX="5.875" PointY="3.4721529134114579" />
<ConnectorPoint PointX="4.375" PointY="3.4721529134114579" />
</AssociationConnector>
<AssociationConnector Association="GraphModel.Person_PersonToLocation">
<ConnectorPoint PointX="6.625" PointY="4.677958984375" />
<ConnectorPoint PointX="6.625" PointY="5.1875" />
<ConnectorPoint PointX="2.625" PointY="5.1875" />
</AssociationConnector>
<AssociationConnector Association="GraphModel.Location_PersonToLocation">
<ConnectorPoint PointX="7.75" PointY="5.4791666666666661" />
<ConnectorPoint PointX="2.625" PointY="5.4791666666666661" />
</AssociationConnector>
</Diagram>
</edmx:Diagrams>
</edmx:Designer>
</edmx:Edmx>
最佳答案
这是一个非常不受欢迎的解决方案,因为它激增了您需要的列数。
对于上面的链接/节点示例,生成的数据库架构如下所示:
SQL:
USE [GraphExample2]
GO
/****** Object: Table [dbo].[Node] Script Date: 02/26/2009 15:45:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Node](
[NodeID] [int] IDENTITY(1,1) NOT NULL,
[NodeTypeDiscriminator] [int] NOT NULL,
[Name] [varchar](255) NOT NULL,
[Description] [varchar](1023) NULL,
CONSTRAINT [PK_Node] PRIMARY KEY CLUSTERED
(
[NodeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Link] Script Date: 02/26/2009 15:45:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Link](
[LinkID] [int] IDENTITY(1,1) NOT NULL,
[LinkTypeDiscriminator] [int] NOT NULL,
[LeaderID] [int] NULL,
[FollowerID] [int] NULL,
[PersonID] [int] NULL,
[LocationID] [int] NULL,
[Name] [varchar](255) NULL,
[Description] [varchar](1023) NULL,
CONSTRAINT [PK_Link] PRIMARY KEY CLUSTERED
(
[LinkID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: ForeignKey [FK_Link_Node_Follower] Script Date: 02/26/2009 15:45:53 ******/
ALTER TABLE [dbo].[Link] WITH CHECK ADD CONSTRAINT [FK_Link_Node_Follower] FOREIGN KEY([FollowerID])
REFERENCES [dbo].[Node] ([NodeID])
GO
ALTER TABLE [dbo].[Link] CHECK CONSTRAINT [FK_Link_Node_Follower]
GO
/****** Object: ForeignKey [FK_Link_Node_Leader] Script Date: 02/26/2009 15:45:53 ******/
ALTER TABLE [dbo].[Link] WITH CHECK ADD CONSTRAINT [FK_Link_Node_Leader] FOREIGN KEY([LeaderID])
REFERENCES [dbo].[Node] ([NodeID])
GO
ALTER TABLE [dbo].[Link] CHECK CONSTRAINT [FK_Link_Node_Leader]
GO
/****** Object: ForeignKey [FK_Link_Node_Location] Script Date: 02/26/2009 15:45:53 ******/
ALTER TABLE [dbo].[Link] WITH CHECK ADD CONSTRAINT [FK_Link_Node_Location] FOREIGN KEY([LocationID])
REFERENCES [dbo].[Node] ([NodeID])
GO
ALTER TABLE [dbo].[Link] CHECK CONSTRAINT [FK_Link_Node_Location]
GO
/****** Object: ForeignKey [FK_Link_Node_Person] Script Date: 02/26/2009 15:45:53 ******/
ALTER TABLE [dbo].[Link] WITH CHECK ADD CONSTRAINT [FK_Link_Node_Person] FOREIGN KEY([PersonID])
REFERENCES [dbo].[Node] ([NodeID])
GO
ALTER TABLE [dbo].[Link] CHECK CONSTRAINT [FK_Link_Node_Person]
GO
EDMX:
<?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="GraphModel.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="GraphModelStoreContainer">
<EntitySet Name="Link" EntityType="GraphModel.Store.Link" store:Type="Tables" Schema="dbo" />
<EntitySet Name="Node" EntityType="GraphModel.Store.Node" store:Type="Tables" Schema="dbo" />
<AssociationSet Name="FK_Link_Node_Follower" Association="GraphModel.Store.FK_Link_Node_Follower">
<End Role="Node" EntitySet="Node" />
<End Role="Link" EntitySet="Link" />
</AssociationSet>
<AssociationSet Name="FK_Link_Node_Leader" Association="GraphModel.Store.FK_Link_Node_Leader">
<End Role="Node" EntitySet="Node" />
<End Role="Link" EntitySet="Link" />
</AssociationSet>
<AssociationSet Name="FK_Link_Node_Location" Association="GraphModel.Store.FK_Link_Node_Location">
<End Role="Node" EntitySet="Node" />
<End Role="Link" EntitySet="Link" />
</AssociationSet>
<AssociationSet Name="FK_Link_Node_Person" Association="GraphModel.Store.FK_Link_Node_Person">
<End Role="Node" EntitySet="Node" />
<End Role="Link" EntitySet="Link" />
</AssociationSet>
</EntityContainer>
<EntityType Name="Link">
<Key>
<PropertyRef Name="LinkID" />
</Key>
<Property Name="LinkID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="LinkTypeDiscriminator" Type="int" Nullable="false" />
<Property Name="LeaderID" Type="int" />
<Property Name="FollowerID" Type="int" />
<Property Name="PersonID" Type="int" />
<Property Name="LocationID" Type="int" />
<Property Name="Name" Type="varchar" MaxLength="255" />
<Property Name="Description" Type="varchar" MaxLength="1023" />
</EntityType>
<EntityType Name="Node">
<Key>
<PropertyRef Name="NodeID" />
</Key>
<Property Name="NodeID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="NodeTypeDiscriminator" Type="int" Nullable="false" />
<Property Name="Name" Type="varchar" Nullable="false" MaxLength="255" />
<Property Name="Description" Type="varchar" MaxLength="1023" />
</EntityType>
<Association Name="FK_Link_Node_Follower">
<End Role="Node" Type="GraphModel.Store.Node" Multiplicity="0..1" />
<End Role="Link" Type="GraphModel.Store.Link" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Node">
<PropertyRef Name="NodeID" />
</Principal>
<Dependent Role="Link">
<PropertyRef Name="FollowerID" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Link_Node_Leader">
<End Role="Node" Type="GraphModel.Store.Node" Multiplicity="0..1" />
<End Role="Link" Type="GraphModel.Store.Link" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Node">
<PropertyRef Name="NodeID" />
</Principal>
<Dependent Role="Link">
<PropertyRef Name="LeaderID" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Link_Node_Location">
<End Role="Node" Type="GraphModel.Store.Node" Multiplicity="0..1" />
<End Role="Link" Type="GraphModel.Store.Link" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Node">
<PropertyRef Name="NodeID" />
</Principal>
<Dependent Role="Link">
<PropertyRef Name="LocationID" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Link_Node_Person">
<End Role="Node" Type="GraphModel.Store.Node" Multiplicity="0..1" />
<End Role="Link" Type="GraphModel.Store.Link" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Node">
<PropertyRef Name="NodeID" />
</Principal>
<Dependent Role="Link">
<PropertyRef Name="PersonID" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema>
</edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema xmlns="http://schemas.microsoft.com/ado/2006/04/edm" Namespace="GraphModel" Alias="Self">
<EntityContainer Name="GraphModelContainer" >
<EntitySet Name="NodeSet" EntityType="GraphModel.Node" />
<EntitySet Name="LinkSet" EntityType="GraphModel.Link" />
<AssociationSet Name="PersonPersonToPerson_Leader" Association="GraphModel.PersonPersonToPerson_Leader">
<End Role="Person" EntitySet="NodeSet" />
<End Role="PersonToPerson" EntitySet="LinkSet" />
</AssociationSet>
<AssociationSet Name="PersonPersonToPerson_Follower" Association="GraphModel.PersonPersonToPerson_Follower">
<End Role="Person" EntitySet="NodeSet" />
<End Role="PersonToPerson" EntitySet="LinkSet" />
</AssociationSet>
<AssociationSet Name="Person_PersonToLocation" Association="GraphModel.Person_PersonToLocation">
<End Role="Person" EntitySet="NodeSet" />
<End Role="PersonToLocation" EntitySet="LinkSet" />
</AssociationSet>
<AssociationSet Name="Location_PersonToLocation" Association="GraphModel.Location_PersonToLocation">
<End Role="Location" EntitySet="NodeSet" />
<End Role="PersonToLocation" EntitySet="LinkSet" />
</AssociationSet>
</EntityContainer>
<EntityType Name="Node" Abstract="true">
<Key>
<PropertyRef Name="NodeId" />
</Key>
<Property Name="NodeId" Type="Int32" Nullable="false" />
<Property Name="Name" Type="String" Nullable="false" />
<Property Name="Description" Type="String" Nullable="true" />
</EntityType>
<EntityType Name="Person" BaseType="GraphModel.Node" >
<NavigationProperty Name="Leaders" Relationship="GraphModel.PersonPersonToPerson_Leader" FromRole="Person" ToRole="PersonToPerson" />
<NavigationProperty Name="Followers" Relationship="GraphModel.PersonPersonToPerson_Follower" FromRole="Person" ToRole="PersonToPerson" />
<NavigationProperty Name="Locations" Relationship="GraphModel.Person_PersonToLocation" FromRole="Person" ToRole="PersonToLocation" />
</EntityType>
<EntityType Name="Location" BaseType="GraphModel.Node" >
<NavigationProperty Name="Visitors" Relationship="GraphModel.Location_PersonToLocation" FromRole="Location" ToRole="PersonToLocation" />
</EntityType>
<EntityType Name="Link" Abstract="true">
<Key>
<PropertyRef Name="LinkId" />
</Key>
<Property Name="LinkId" Type="Int32" Nullable="false" />
<Property Name="Name" Type="String" Nullable="true" />
<Property Name="Description" Type="String" Nullable="true" />
</EntityType>
<EntityType Name="PersonToPerson" BaseType="GraphModel.Link" >
<NavigationProperty Name="Leader" Relationship="GraphModel.PersonPersonToPerson_Leader" FromRole="PersonToPerson" ToRole="Person" />
<NavigationProperty Name="Follower" Relationship="GraphModel.PersonPersonToPerson_Follower" FromRole="PersonToPerson" ToRole="Person" />
</EntityType>
<EntityType Name="PersonToLocation" BaseType="GraphModel.Link" >
<NavigationProperty Name="Person" Relationship="GraphModel.Person_PersonToLocation" FromRole="PersonToLocation" ToRole="Person" />
<NavigationProperty Name="Location" Relationship="GraphModel.Location_PersonToLocation" FromRole="PersonToLocation" ToRole="Location" />
</EntityType>
<Association Name="PersonPersonToPerson_Leader">
<End Type="GraphModel.Person" Role="Person" Multiplicity="1" />
<End Type="GraphModel.PersonToPerson" Role="PersonToPerson" Multiplicity="*" />
</Association>
<Association Name="PersonPersonToPerson_Follower">
<End Type="GraphModel.Person" Role="Person" Multiplicity="1" />
<End Type="GraphModel.PersonToPerson" Role="PersonToPerson" Multiplicity="*" />
</Association>
<Association Name="Person_PersonToLocation">
<End Type="GraphModel.Person" Role="Person" Multiplicity="1" />
<End Type="GraphModel.PersonToLocation" Role="PersonToLocation" Multiplicity="*" />
</Association>
<Association Name="Location_PersonToLocation">
<End Type="GraphModel.Location" Role="Location" Multiplicity="1" />
<End Type="GraphModel.PersonToLocation" Role="PersonToLocation" Multiplicity="*" />
</Association>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS" Space="C-S">
<Alias Key="Model" Value="GraphModel" />
<Alias Key="Target" Value="GraphModel.Store" />
<EntityContainerMapping CdmEntityContainer="GraphModelContainer" StorageEntityContainer="GraphModelStoreContainer">
<EntitySetMapping Name="LinkSet">
<EntityTypeMapping TypeName="IsTypeOf(GraphModel.Link)">
<MappingFragment StoreEntitySet="Link">
<ScalarProperty Name="Description" ColumnName="Description" />
<ScalarProperty Name="Name" ColumnName="Name" />
<ScalarProperty Name="LinkId" ColumnName="LinkID" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(GraphModel.PersonToPerson)">
<MappingFragment StoreEntitySet="Link" >
<ScalarProperty Name="LinkId" ColumnName="LinkID" />
<Condition ColumnName="LinkTypeDiscriminator" Value="1" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(GraphModel.PersonToLocation)">
<MappingFragment StoreEntitySet="Link" >
<ScalarProperty Name="LinkId" ColumnName="LinkID" />
<Condition ColumnName="LinkTypeDiscriminator" Value="2" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="NodeSet">
<EntityTypeMapping TypeName="IsTypeOf(GraphModel.Node)">
<MappingFragment StoreEntitySet="Node">
<ScalarProperty Name="Description" ColumnName="Description" />
<ScalarProperty Name="Name" ColumnName="Name" />
<ScalarProperty Name="NodeId" ColumnName="NodeID" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(GraphModel.Person)">
<MappingFragment StoreEntitySet="Node" >
<ScalarProperty Name="NodeId" ColumnName="NodeID" />
<Condition ColumnName="NodeTypeDiscriminator" Value="1" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(GraphModel.Location)">
<MappingFragment StoreEntitySet="Node" >
<ScalarProperty Name="NodeId" ColumnName="NodeID" />
<Condition ColumnName="NodeTypeDiscriminator" Value="2" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<AssociationSetMapping Name="PersonPersonToPerson_Follower" TypeName="GraphModel.PersonPersonToPerson_Follower" StoreEntitySet="Link">
<EndProperty Name="Person">
<ScalarProperty Name="NodeId" ColumnName="FollowerID" />
</EndProperty>
<EndProperty Name="PersonToPerson">
<ScalarProperty Name="LinkId" ColumnName="LinkID" />
</EndProperty>
</AssociationSetMapping>
<AssociationSetMapping Name="PersonPersonToPerson_Leader" TypeName="GraphModel.PersonPersonToPerson_Leader" StoreEntitySet="Link">
<EndProperty Name="Person">
<ScalarProperty Name="NodeId" ColumnName="LeaderID" />
</EndProperty>
<EndProperty Name="PersonToPerson">
<ScalarProperty Name="LinkId" ColumnName="LinkID" />
</EndProperty>
</AssociationSetMapping>
<AssociationSetMapping Name="Person_PersonToLocation" TypeName="GraphModel.Person_PersonToLocation" StoreEntitySet="Link">
<EndProperty Name="Person">
<ScalarProperty Name="NodeId" ColumnName="PersonID" />
</EndProperty>
<EndProperty Name="PersonToLocation">
<ScalarProperty Name="LinkId" ColumnName="LinkID" />
</EndProperty>
</AssociationSetMapping>
<AssociationSetMapping Name="Location_PersonToLocation" TypeName="GraphModel.Location_PersonToLocation" StoreEntitySet="Link">
<EndProperty Name="Location">
<ScalarProperty Name="NodeId" ColumnName="LocationID" />
</EndProperty>
<EndProperty Name="PersonToLocation">
<ScalarProperty Name="LinkId" ColumnName="LinkID" />
</EndProperty>
</AssociationSetMapping>
</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="GraphModel" ZoomLevel="114" >
<EntityTypeShape EntityType="GraphModel.Node" Width="1.5" PointX="5.875" PointY="1.375" Height="1.427958984375" />
<EntityTypeShape EntityType="GraphModel.Person" Width="1.5" PointX="5.875" PointY="3.25" Height="1.4279589843749996" />
<EntityTypeShape EntityType="GraphModel.Location" Width="1.5" PointX="7.75" PointY="4.625" Height="1.0992643229166665" />
<InheritanceConnector EntityType="GraphModel.Location">
<ConnectorPoint PointX="7.375" PointY="2.4176741536458342" />
<ConnectorPoint PointX="8.5" PointY="2.4176741536458342" />
<ConnectorPoint PointX="8.5" PointY="4.625" />
</InheritanceConnector>
<EntityTypeShape EntityType="GraphModel.Link" Width="1.5" PointX="2.875" PointY="1.375" Height="1.427958984375" />
<EntityTypeShape EntityType="GraphModel.PersonToPerson" Width="1.75" PointX="2.75" PointY="3.25" Height="1.2636116536458326" />
<InheritanceConnector EntityType="GraphModel.PersonToPerson" ManuallyRouted="false">
<ConnectorPoint PointX="3.625" PointY="2.802958984375" />
<ConnectorPoint PointX="3.625" PointY="3.25" />
</InheritanceConnector>
<InheritanceConnector EntityType="GraphModel.Person">
<ConnectorPoint PointX="6.625" PointY="3.4603483072916683" />
<ConnectorPoint PointX="6.625" PointY="3.25" />
</InheritanceConnector>
<EntityTypeShape EntityType="GraphModel.PersonToLocation" Width="1.875" PointX="0.75" PointY="4.625" Height="1.2636116536458326" />
<InheritanceConnector EntityType="GraphModel.PersonToLocation">
<ConnectorPoint PointX="2.875" PointY="2.4176741536458342" />
<ConnectorPoint PointX="1.65625" PointY="2.4176741536458342" />
<ConnectorPoint PointX="1.65625" PointY="4.625" />
</InheritanceConnector>
<AssociationConnector Association="GraphModel.PersonPersonToPerson_Leader">
<ConnectorPoint PointX="5.875" PointY="3.8818058268229163" />
<ConnectorPoint PointX="4.5" PointY="3.8818058268229163" />
</AssociationConnector>
<AssociationConnector Association="GraphModel.PersonPersonToPerson_Follower">
<ConnectorPoint PointX="5.875" PointY="3.5034029134114579" />
<ConnectorPoint PointX="4.5" PointY="3.5034029134114579" />
</AssociationConnector>
<AssociationConnector Association="GraphModel.Person_PersonToLocation">
<ConnectorPoint PointX="6.625" PointY="4.677958984375" />
<ConnectorPoint PointX="6.625" PointY="5.0078214863281243" />
<ConnectorPoint PointX="2.625" PointY="5.0078214863281243" />
</AssociationConnector>
<AssociationConnector Association="GraphModel.Location_PersonToLocation">
<ConnectorPoint PointX="7.75" PointY="5.40018798828125" />
<ConnectorPoint PointX="2.625" PointY="5.40018798828125" />
</AssociationConnector>
</Diagram>
</edmx:Diagrams>
</edmx:Designer>
</edmx:Edmx>
关于c# - ADO EF - TPH 中派生类型之间的错误映射关联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/558462/
我需要将文本放在 中在一个 Div 中,在另一个 Div 中,在另一个 Div 中。所以这是它的样子: #document Change PIN
奇怪的事情发生了。 我有一个基本的 html 代码。 html,头部, body 。(因为我收到了一些反对票,这里是完整的代码) 这是我的CSS: html { backgroun
我正在尝试将 Assets 中的一组图像加载到 UICollectionview 中存在的 ImageView 中,但每当我运行应用程序时它都会显示错误。而且也没有显示图像。 我在ViewDidLoa
我需要根据带参数的 perl 脚本的输出更改一些环境变量。在 tcsh 中,我可以使用别名命令来评估 perl 脚本的输出。 tcsh: alias setsdk 'eval `/localhome/
我使用 Windows 身份验证创建了一个新的 Blazor(服务器端)应用程序,并使用 IIS Express 运行它。它将显示一条消息“Hello Domain\User!”来自右上方的以下 Ra
这是我的方法 void login(Event event);我想知道 Kotlin 中应该如何 最佳答案 在 Kotlin 中通配符运算符是 * 。它指示编译器它是未知的,但一旦知道,就不会有其他类
看下面的代码 for story in book if story.title.length < 140 - var story
我正在尝试用 C 语言学习字符串处理。我写了一个程序,它存储了一些音乐轨道,并帮助用户检查他/她想到的歌曲是否存在于存储的轨道中。这是通过要求用户输入一串字符来完成的。然后程序使用 strstr()
我正在学习 sscanf 并遇到如下格式字符串: sscanf("%[^:]:%[^*=]%*[*=]%n",a,b,&c); 我理解 %[^:] 部分意味着扫描直到遇到 ':' 并将其分配给 a。:
def char_check(x,y): if (str(x) in y or x.find(y) > -1) or (str(y) in x or y.find(x) > -1):
我有一种情况,我想将文本文件中的现有行包含到一个新 block 中。 line 1 line 2 line in block line 3 line 4 应该变成 line 1 line 2 line
我有一个新项目,我正在尝试设置 Django 调试工具栏。首先,我尝试了快速设置,它只涉及将 'debug_toolbar' 添加到我的已安装应用程序列表中。有了这个,当我转到我的根 URL 时,调试
在 Matlab 中,如果我有一个函数 f,例如签名是 f(a,b,c),我可以创建一个只有一个变量 b 的函数,它将使用固定的 a=a1 和 c=c1 调用 f: g = @(b) f(a1, b,
我不明白为什么 ForEach 中的元素之间有多余的垂直间距在 VStack 里面在 ScrollView 里面使用 GeometryReader 时渲染自定义水平分隔线。 Scrol
我想知道,是否有关于何时使用 session 和 cookie 的指南或最佳实践? 什么应该和什么不应该存储在其中?谢谢! 最佳答案 这些文档很好地了解了 session cookie 的安全问题以及
我在 scipy/numpy 中有一个 Nx3 矩阵,我想用它制作一个 3 维条形图,其中 X 轴和 Y 轴由矩阵的第一列和第二列的值、高度确定每个条形的 是矩阵中的第三列,条形的数量由 N 确定。
假设我用两种不同的方式初始化信号量 sem_init(&randomsem,0,1) sem_init(&randomsem,0,0) 现在, sem_wait(&randomsem) 在这两种情况下
我怀疑该值如何存储在“WORD”中,因为 PStr 包含实际输出。? 既然Pstr中存储的是小写到大写的字母,那么在printf中如何将其给出为“WORD”。有人可以吗?解释一下? #include
我有一个 3x3 数组: var my_array = [[0,1,2], [3,4,5], [6,7,8]]; 并想获得它的第一个 2
我意识到您可以使用如下方式轻松检查焦点: var hasFocus = true; $(window).blur(function(){ hasFocus = false; }); $(win
我是一名优秀的程序员,十分优秀!