术语“添加 - 迁移”不会被识别为cmdlet,函数,脚本文件或可操作程序的名称

时间:2016-11-23 22:50:14

标签: json asp.net-core entity-framework-6 nuget

请帮我解决这个问题。下面是我的project.json文件。

DECLARE @Table AS TABLE (visitor CHAR(1), VisitId INT, ConversionId INT, Channel VARCHAR(15))
INSERT INTO @Table VALUES  ('a',1, 11,'email'),('a',2, 12,'email'),('a',3, 13,'direct')
,('b',4, 14,'seo'),('b',5, 15,'direct'),('b',6, 16,'email'),('c',7, 17,'seo')
,('c',8, 18,'direct'),('c',9, 19,'direct')

    ;WITH cte AS (
        SELECT
           visitor
           ,VisitId
           ,Channel
           ,ConversionId
           ,DirectConversion = CASE WHEN Channel = 'direct' THEN ConversionId END
           ,ChannelRowNumber = ROW_NUMBER() OVER (PARTITION BY visitor
              ORDER BY
                 CASE WHEN Channel = 'direct' THEN 1 ELSE 0 END
                 ,ConversionId DESC)

        FROM
           @Table
    )

    SELECT
        visitor
        ,MaxVisitId = MAX(VisitId)
        ,MaxVisitIdOfNonDirect = MAX(CASE WHEN DirectConversion IS NULL THEN VisitId END)
        ,NumOfVisits = COUNT(DISTINCT VisitId)
        ,Channel = MAX(CASE WHEN ChannelRowNumber = 1 THEN Channel END)
        ,NumOfConversions = COUNT(DISTINCT ConversionId)
        ,NumOfDirectConversions = COUNT(DISTINCT DirectConversion)
        ,NumOfNonDirectConversions = COUNT(DISTINCT ConversionId) - COUNT(DISTINCT DirectConversion)
    FROM
        cte
    GROUP BY
        visitor

当我创建一个全新的项目,并将相同的project.json文件添加到项目中时,“Add-Migration”命令工作正常。

当我在互联网上查看时,人们谈论重启VS2015,我已经完成了所有这些并且问题仍然存在。

1 个答案:

答案 0 :(得分:0)

您是否尝试在Enable-Migrations之前运行Add-Migration命令?

如果这不起作用,this answer似乎建议从Nuget重新安装Entity Framework