Stefan
Stefan

Reputation: 97

Why does Entity Framework select all tables, columns and other info

After using the profiler we noticed that our application loads slower because of a query that Entity Framework executes.

SELECT 
    [Extent1].[TABLE_NAME] AS [TABLE_NAME], 
    [Extent1].[COLUMN_NAME] AS [COLUMN_NAME], 
    [Extent1].[TABLE_CATALOG] AS [TABLE_CATALOG], 
    [Extent1].[TABLE_SCHEMA] AS [TABLE_SCHEMA], 
    [Extent1].[ORDINAL_POSITION] AS [ORDINAL_POSITION], 
    [Extent1].[COLUMN_DEFAULT] AS [COLUMN_DEFAULT], 
    [Extent1].[IS_NULLABLE] AS [IS_NULLABLE], 
    [Extent1].[DATA_TYPE] AS [DATA_TYPE], 
    [Extent1].[CHARACTER_MAXIMUM_LENGTH] AS [CHARACTER_MAXIMUM_LENGTH], 
    [Extent1].[CHARACTER_OCTET_LENGTH] AS [CHARACTER_OCTET_LENGTH], 
    [Extent1].[NUMERIC_PRECISION] AS [NUMERIC_PRECISION], 
    [Extent1].[NUMERIC_PRECISION_RADIX] AS [NUMERIC_PRECISION_RADIX], 
    [Extent1].[NUMERIC_SCALE] AS [NUMERIC_SCALE], 
    [Extent1].[DATETIME_PRECISION] AS [DATETIME_PRECISION], 
    [Extent1].[CHARACTER_SET_CATALOG] AS [CHARACTER_SET_CATALOG], 
    [Extent1].[CHARACTER_SET_SCHEMA] AS [CHARACTER_SET_SCHEMA], 
    [Extent1].[CHARACTER_SET_NAME] AS [CHARACTER_SET_NAME], 
    [Extent1].[COLLATION_CATALOG] AS [COLLATION_CATALOG], 
    [Extent1].[COLLATION_SCHEMA] AS [COLLATION_SCHEMA], 
    [Extent1].[COLLATION_NAME] AS [COLLATION_NAME], 
    [Extent1].[DOMAIN_CATALOG] AS [DOMAIN_CATALOG], 
    [Extent1].[DOMAIN_SCHEMA] AS [DOMAIN_SCHEMA], 
    [Extent1].[DOMAIN_NAME] AS [DOMAIN_NAME]
FROM [information_schema].[columns] AS [Extent1]

So this query gets all the information about the database. But we're wondering why and if it is possible to stop it or make it faster.

Upvotes: 2

Views: 668

Answers (1)

user853710
user853710

Reputation: 1767

This way the EF is making sure that the model in the app is valid and the model schema is in sync with the DB schema. EF just works this way

Upvotes: 1

Related Questions