打赏

sqlserver 获得行号作为唯一id

当sqlserver创建的view没有唯一的标识字段里,entity framework codefirst配置会出现错误,因为取其行号作为唯一标识列

CREATE VIEW [SafeWatch].[MissionInvalidItemView]
AS
SELECT ROW_NUMBER() OVER(ORDER BY aci.Id ASC) AS RowNumber,
ac.AppCheckItemId,

FROM SafeWatch.AppCheck ac
INNER JOIN SafeWatch.AppCheckItem aci ON aci.Id = ac.AppCheckItemId
LEFT JOIN SafeWatch.MissionInvalidItem mii ON mii.AppCheckId = ac.Id
WHERE ac.CheckResult>1

 

GO

posted @ 2016-05-03 15:36  KiteRunner1988  阅读(1083)  评论(0编辑  收藏  举报