How to disable query output in the EdmMetadata table?

I am using EF Code First in my new project. I will not use the automatic migration function and do not have the table [__MigrationHistory] in db. But, looking at Profiler, I always see that EF issues such a request before any other request:

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

Is it possible to disable this feature?

+6
source share
1 answer

The only way to disable this feature is to not use a database initializer. When you use the database initializer (you expect EF to create or modify the database), you will always have queries on this table.

To disable the database initializer, use this when loading your application:

 Database.SetInitializer<YourContext>(null); 
+11
source

Source: https://habr.com/ru/post/919417/


All Articles