EF 4.3代码首次迁移 - 解压缩__MigrationHistory模型 [英] EF 4.3 Code First Migrations - Uncompress __MigrationHistory Model

查看:230
本文介绍了EF 4.3代码首次迁移 - 解压缩__MigrationHistory模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何解压缩/读取存储在EF 4.3 Code First Migrations __MigrationHistory表中的压缩模型?



我在该评论,我可以使用zip / gzip解压缩,但我不知道我应该怎么做。



问题是我已经改变了ef模型类,但是当我调用add-migration时,会生成一个空的迁移。我认为这是因为我的模型类的更改已经分配给现有的迁移:(

解决方案

可能是一个很好的起点 - 在你的情况下不行)



我认为你可能会发现这很有用 - 你'只是<强调需要在相反的方向工作,我想(我只是暗示这里可能是什么方向,你必须检查出来,测试自己)...

$ a bref =nofollow > http://brice-lambson.blogspot.com/2012/05/using-entity-framework-code-first-with.html



它使用以下代码...

  private byte [] GetModel(TContext context)
{
using (var memoryStream = new MemoryStream())
{
using(var gzipStream = new GZipStream(
memoryStream,
CompressionMode.Compress))
使用(var xmlWriter = XmlWriter.Create(
gzipStream,
new XmlWriterSettings {Indent = true}))
{
EdmxWriter.WriteEdmx上下文,xmlWriter);
}

return memoryStream.ToArray();
}
}

以序列化模型。



但是,据我所知(如果我理解正确)你需要在另一个方向...



快速搜索没有显示相当的阅读器 - 您可以下载最新的 EF6代码 - 或者也找到EF5一个(如果需要的话我会在后面链接)。



读者:



其实这可能更接近你想要的: / p>

http://edmxdom.codeplex.com/

(我没有尝试过但是从MS链接)



http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/线程/ 1546548f-9f90-4cc2-b1b2-28cf7e9d1cb5 /



并检查有关使用 MetadataWorkspace



如果您需要有关 MetadataWorkspace 的更多信息,我将发布一些关于该主题的帖子。你可以得到最多的信息 - 你需要排序反向什么 EdmxWriter 正在做。



本质上,您正在寻找实体框架Edmx reader



EdmxDOM:



我刚刚检查出来 - 做你需要的Edmx格式管理。

这是一个'VB'项目 - 但是你可以通过这个工作来实现



有什么似乎是一个读者(再次,不确定,刚刚经历了这个,正如我所知道的作家,但从来没有在这个部分,方向)...

  Public Sub LoadFile(ByVal fileName As String)

code> Edmx.vb


How can I uncompress/read the compressed models stored in the EF 4.3 Code First Migrations __MigrationHistory table?

I found a hint in this comment, that I can uncompress it using zip/gzip, but I don't know how exactly I should do this.

The problem is that I have changed something in my ef model classes, but when I call "add-migration" an empty migration ist generated. I think that is because the changes of my model classes are already assigned to an existing migration :(

解决方案

(this may be a good starting point - won't work in your case)

I think you may find this useful - you 'just' need to work it out in the opposite direction, I think (I'm just hinting here as to what might be the direction, you'll have to check it out, test yourself)...

http://brice-lambson.blogspot.com/2012/05/using-entity-framework-code-first-with.html

It uses the following code...

private byte[] GetModel(TContext context)
{
    using (var memoryStream = new MemoryStream())
    {
        using (var gzipStream = new GZipStream(
            memoryStream,
            CompressionMode.Compress))
        using (var xmlWriter = XmlWriter.Create(
            gzipStream,
            new XmlWriterSettings { Indent = true }))
        {
            EdmxWriter.WriteEdmx(context, xmlWriter);
        }

        return memoryStream.ToArray();
    }
}  

to serialize the model.

However, as I understand (if I understand it properly) you need it in the other direction...

Quick search didn't show the equivalent reader - you can download the latest EF6 code - or also find EF5 one (I'll link in later if needed).

Reader:

Actually this may be closer to what you want:

http://edmxdom.codeplex.com/
(I haven't tried it out but was linked from MS)

http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/1546548f-9f90-4cc2-b1b2-28cf7e9d1cb5/

And check the response about using MetadataWorkspace

If you need more info on the MetadataWorkspace I'll post some posts I made on that subject. You can get most info out - you'll need to sort 'reverse' what EdmxWriter is doing.

Essentially, you're looking for entity framework Edmx reader.

EdmxDOM:

I just checked it out fast - and it seems to be doing the Edmx format management you need.
It's a 'VB' project - but you can work through that

There is what seems to be a 'reader' (again, not sure, just went through this, as I know about the writer - but never worked w/ this part, direction)...

Public Sub LoadFile(ByVal fileName As String)  

In the Edmx.vb

这篇关于EF 4.3代码首次迁移 - 解压缩__MigrationHistory模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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