1

我使用 Entity Framework 5.0 版从数据库构建了实体模型。以下 DDL 用于创建表:

CREATE TABLE [dbo].[Replenishment](
    [replenishmentId] [int] IDENTITY(1,1) NOT NULL,
    [locationID] [int] NOT NULL,
    [inventoryItemId] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
    ([replenishmentId] 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

ALTER TABLE [dbo].[Replenishment]  
    WITH CHECK ADD  CONSTRAINT [FKReplenishm163678]
    FOREIGN KEY([inventoryItemId])
    REFERENCES [dbo].[InventoryItem] ([inventoryItemId])
GO

ALTER TABLE [dbo].[Replenishment] CHECK CONSTRAINT [FKReplenishm163678]
GO

ALTER TABLE [dbo].[Replenishment]  
    WITH CHECK ADD  CONSTRAINT [FKReplenishm580804] 
    FOREIGN KEY([locationID])
    REFERENCES [dbo].[Location] ([locationID])
GO

ALTER TABLE [dbo].[Replenishment] CHECK CONSTRAINT [FKReplenishm580804]
GO

当我使用表 Replenishment、Location 和 InventoryItem 构建实体模型时,所有三个表都显示在模型中,但没有任何关系出现。

有谁知道为什么没有出现外键或导航属性?

==================================================== ===========================

这是来自关联表的 DDL: 这是来自其他两个表的 ddl:

CREATE TABLE [dbo].[Location](
[locationID] [int] IDENTITY(1,1) NOT NULL,
[addressID] [int] NULL,
[availabilityStatusID] [int] NOT NULL,
[inLocationId] [int] NULL,
[locationTypeID] [int] NOT NULL,
[locationName] [varchar](40) NOT NULL,
[locationDescription] [varchar](100) NOT NULL,
[locationAnchorX] [int] NULL,
[locationAnchorY] [int] NULL,
[locationImage] [varchar](255) NULL,
[diagramLayerId] [int] NULL,
[locationShapeParameters] [varchar](max) NULL,
[locationHeight] [int] NULL,
    [locationWidth] [int] NULL,
    [locationColor] [varchar](20) NULL,
PRIMARY KEY CLUSTERED 
(
[locationID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY     = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Location]  WITH CHECK ADD  CONSTRAINT [FKLocation209934] FOREIGN KEY([inLocationId])
REFERENCES [dbo].[Location] ([locationID])
GO

ALTER TABLE [dbo].[Location] CHECK CONSTRAINT [FKLocation209934]
GO


CREATE TABLE [dbo].[InventoryItem](
[inventoryItemId] [int] IDENTITY(1,1) NOT NULL,
[itemTaxonomyId] [int] NOT NULL,
[itemDescription] [varchar](100) NOT NULL,
[itemCode] [varchar](40) NULL,
[batchControlled] [bit] NOT NULL,
[assemblyDefinitionID] [int] NULL,
PRIMARY KEY CLUSTERED 
(
    [inventoryItemId] 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
4

1 回答 1

0

我相信我找到了问题所在。我一直在做一些使用 SQL Server 身份验证的工作和一些使用 Windows 身份验证的工作。我的 Visual Studio 看不到使用 Windows 身份验证输入的信息,它使用 SQL Server 身份验证进行连接。

经过进一步研究,我发现情况并非如此。我仍然对此感到困惑。

于 2013-01-16T21:28:04.127 回答