压缩模型如何存储在EF 4.3 Code First Migrations __MigrationHistory表中? [英] How are the compressed models stored in the EF 4.3 Code First Migrations __MigrationHistory table created?

查看:462
本文介绍了压缩模型如何存储在EF 4.3 Code First Migrations __MigrationHistory表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Code First Migrations(实体框架4.3),我想获得当前模型的压缩二进制版本,以便我可以手动将其与存储在<$ c $中的最新模型进行比较c> __ MigrationHistory 表(或一个我已经存储在文本文件中)。



有$ code > EdmMetadata.TryGetModelHash()方法,但这被标记为已弃用,如果可能,我想避免(为了将来的原因)。



如何在EF 4.3下执行此操作?



编辑:从更多的调查和 Pawel的答案我已经弄清楚,这个字段不再存储哈希,而是模型的压缩二进制表示。这是我正在尝试创建的。

__ MigrationHistory table no更长的包含模型的哈希。它现在包含压缩格式的模型。此外,验证模型是否改变不再依赖于比较哈希,因为迁移需要知道什么改变和如何改变。



EdmMetadata 是在Migrations与4.3 / 5.0中实体Framowork集成之前使用的表,在由EF 4.3+创建的数据库中创建。您还可以在这里找到一些其他细节: http://blog.oneunicorn.com/2012/01/13/ef-4-3-beta-1-what-happened-to-that-edmmetadata-table/


I'm working with Code First Migrations (Entity Framework 4.3) and I'd like to get a compressed binary version of the current model, so that I can manually compare it to the latest model stored in the __MigrationHistory table (or to one I have stored in a text file).

There is the EdmMetadata.TryGetModelHash() method, but that's marked as deprecated and I want to avoid it if possible (for future-proofing reasons).

How would I do this under EF 4.3?

Edit: From a bit more investigation and the info in Pawel's answer I've figured out that this field no longer stores a hash but a compressed binary representation of the model. It's this I'm trying to create.

解决方案

__MigrationHistory table no longer contains a hash of the model. Instead it now contains the model in the compressed form. Also, verifying whether the model changed or not no longer relies on just comparing the hash since Migrations need to "know" what changed and how it did change.

EdmMetadata was a table that was being used before Migrations were integrated to Entity Framowork in 4.3/5.0 and won't be created in databases created by EF 4.3+. You can find some additional details here as well: http://blog.oneunicorn.com/2012/01/13/ef-4-3-beta-1-what-happened-to-that-edmmetadata-table/

这篇关于压缩模型如何存储在EF 4.3 Code First Migrations __MigrationHistory表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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