有没有一种简单的方法来验证数据库架构是否正是我希望它是用实体框架?它是、方法来、实体、架构

由网友(黑白颠倒的年华)分享简介:我想我的应用程序,以验证数据库consitency在启动的时候。I want my application to verify database consitency at startup time.有没有一种简单的方法来验证数据库架构是否正是我希望它是用实体框架?Is there an easy way to...

我想我的应用程序,以验证数据库consitency在启动的时候。

I want my application to verify database consitency at startup time.

有没有一种简单的方法来验证数据库架构是否正是我希望它是用实体框架?

Is there an easy way to verify whether or not the database schema is exactly what I expect it to be using Entity Framework?

EF4本身做一些验证。如果一个映射类型包含没有在目标表中,当EF4被物化它触发一个例外列。精细。但也有一些事情也没有做:它不会在第一次验证整个数据库。当目标表中包含未映射的列这不会触发一个例外。

EF4 itself does some verification. If a mapped type contains a column that does not exist in the target table, when EF4 is materializing it triggers an exception. Fine. However there are some things it does not do: It does not verify the entire database at first. It does not trigger an exception when the target table contains a column that is not mapped.

有一个简单的办法可以达到这个目的?

Is there an easy way I can accomplish that?

推荐答案

关于你提到的具体的例子,EF无法知道你不告诉它的模式。如果有未映射一个领域,只要SQL语句(尤其是插入)对阵表EF成功真的不在乎。也许那场去precated,但它仍然必须保持一些旧的应用程序,或者是因为这是一个痛苦和半从活动数据库中删除字段。

As to your specific example, EF can't know what you don't tell it about the schema. If there's a field that isn't mapped, as long as SQL statements (especially inserts) succeed against the table EF really doesn't care. Maybe that field is deprecated, but it still has to be kept for some legacy app, or because it's a pain and a half to remove a field from an active DB.

阅读全文

相关推荐

最新文章