开发者

Why does Entity Framework Code-First (with an existing DB) keep trying get data from an EdmMetadata table?

i'm trying do some Entity Framework Code First programming to an existing database .. but I keep seeing this code in my Sql Profiler :-

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

What the hell is this EdmMetadata t开发者_运维技巧able and why do is my EF code trying to grab the Id and ModelHash from there?

Remember, I'm trying to work against an existing DB.

Cheers :)


There is no Code-First against existing database. If you have database you are doing Database-first. In such case your mapping is driven by database.

EdmMetadata table keeps hash of current code-first model and it allows DbContext detecting changes of model so that database can be recreated. This feature is turned on by default. You can turn it off by removing convention in OnModelCreating:

modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜