2014-02-22 58 views
1

我最近在使用miniprofiler時注意到一些額外的sql調用。EF6升級後的額外SQL調用

它們似乎只在構建完成後出現,而我認爲它們在升級到EF6後出現。

他們只是檢查模型的變化?

我可以放心地忽略它們嗎?

SELECT 
    [GroupBy1].[A1] AS [C1] 
    FROM (SELECT 
     COUNT(1) AS [A1] 
     FROM [dbo].[__MigrationHistory] AS [Extent1] 
    ) AS [GroupBy1] 



SELECT 
    [GroupBy1].[A1] AS [C1] 
    FROM (SELECT 
     COUNT(1) AS [A1] 
     FROM [dbo].[__MigrationHistory] AS [Extent1] 
     WHERE ([Extent1].[ContextKey] = @p__linq__0) AND (@p__linq__0 IS NOT NULL) 
    ) AS [GroupBy1] 


SELECT TOP (1) 
    [Project1].[C1] AS [C1], 
    [Project1].[MigrationId] AS [MigrationId], 
    [Project1].[Model] AS [Model] 
    FROM (SELECT 
     [Extent1].[MigrationId] AS [MigrationId], 
     [Extent1].[Model] AS [Model], 
     1 AS [C1] 
     FROM [dbo].[__MigrationHistory] AS [Extent1] 
     WHERE ([Extent1].[ContextKey] = @p__linq__0) AND (@p__linq__0 IS NOT NULL) 
    ) AS [Project1] 
    ORDER BY [Project1].[MigrationId] DESC 

回答

1

這些DB調用參考Migration HIstory Table新的功能,利用二維碼的首次列入in EF6時:

遷移歷史表是通過代碼首先遷移使用一個表來存儲有關應用於數據庫遷移的詳細信息。默認情況下,數據庫中表的名稱是__MigrationHistory,並且在應用第一次遷移時創建該數據庫。在Entity Framework 5中,如果應用程序使用Microsoft Sql Server數據庫,則此表是系統表。然而,在實體框架6中這已經改變,並且遷移歷史表不再被標記爲系統表。

如果您不使用它們,這些調用不應該造成任何傷害。您可以隨時爲您提供disable themhave EF create DB change scripts

+0

完美答案,非常感謝:) –