How to disable issueing queries against EdmMetadata table?
Asked Answered
D

1

6

I'm using EF Code First in my new project. I'm not going to use Auto Migration feature and have not [__MigrationHistory] table in db. But with looking at Profiler, I can always see EF issues a query like this before any other query:

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

Haw can I disable this feature?

Dibbrun answered 1/7, 2012 at 6:50 Comment(0)
C
11

The only way to disable this feature is not using any database initializer. Once you are using database initializer (you expect EF to create or change database) you will always have queries to this table.

To turn off database initializer use this at the bootstrap of your application:

Database.SetInitializer<YourContext>(null);
Carouse answered 2/7, 2012 at 12:43 Comment(1)
Can someone link to the rationale for why all this meta-querying is turned on by default? I am sure someone has a good reason somewhere, but it is not apparent to me.Pameliapamelina

© 2022 - 2024 — McMap. All rights reserved.