为什么实体框架代码优先(与现有的DB)保持从EdmMetadata表试图获取数据? [英] Why does Entity Framework Code-First (with an existing DB) keep trying get data from an EdmMetadata table?

查看:550
本文介绍了为什么实体框架代码优先(与现有的DB)保持从EdmMetadata表试图获取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一些实体框架代码优先编程到的现有的数据库..但我总是看到在我的SQL事件探查这段代码: -

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

什么是地狱这是EdmMetadata表,为什么我的EF代码试图抓住从那里Id和ModelHash?

What the hell is this EdmMetadata table and why do is my EF code trying to grab the Id and ModelHash from there?

记住,我想。对现有的DB工作

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

干杯:)

推荐答案

有无码,首先对现有的数据库。如果你的数据库,你正在做的数据库一。在这种情况下,你的映射是由数据库驱动。

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表保存当前代码优先模型的哈希,它允许的DbContext 检测模型的变化,使数据库可以重新创建。此功能默认是打开的。

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>();

这篇关于为什么实体框架代码优先(与现有的DB)保持从EdmMetadata表试图获取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆