【发布时间】:2017-06-30 11:51:32
【问题描述】:
我有以下看法:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER VIEW [dbo].[RateAverageValueView] WITH SCHEMABINDING
AS
SELECT
Id = NEWID(),
AverageRateValue = AVG(Value)
FROM dbo.Rate
GO
但我无法将其添加到 EF 模型(edmx 文件)。
我知道它应该有一个主键列,所以我添加了Id = NEWID(),但它不起作用。
有什么问题?
在 Visual Studio 的警告部分中列出了以下错误:
警告:
Error 6013: The table/view 'YoutubeLinks.dbo.RateAverageValueView' does not have a primary key defined and no valid primary key could be inferred. This table/view has been excluded. To use the entity, you will need to review your schema, add the correct keys, and uncomment it.
【问题讨论】:
-
为什么不写一个标量值函数?
-
我只是找到问题的原因以获得更多经验。
-
什么不起作用?请具体。您收到任何错误消息吗?
-
查看警告部分
标签: c# sql entity-framework view