LinqPad queries __MigrationHistory on first run of an EF query

梦想与她 提交于 2019-12-11 04:34:20

问题


My project is EF 5, using DbContext.

I just noticed that the first time I run any Linq query in LinqPad, there is a slight delay, and the generated SQL starts with the following. The subsequent runs, there is no delay and no extra SQL.

Can anyone explain to me what this SQL is, and if I should worry about it?

SELECT TABLE_SCHEMA SchemaName, TABLE_NAME Name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'
GO

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

SELECT TOP (1) 
[Extent1].[Id] AS [Id], 
[Extent1].[ModelHash] AS [ModelHash]
FROM [dbo].[EdmMetadata] AS [Extent1]
ORDER BY [Extent1].[Id] DESC
GO

回答1:


That's EF code first, verifying that your database matches the model to be sure everything will work properly.

Don't worry about it!



来源:https://stackoverflow.com/questions/15164105/linqpad-queries-migrationhistory-on-first-run-of-an-ef-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!