EF 迁移 resx 文件中的目标字段采用哪种格式?

In which format is Target field in the EF Migration resx files?

与 Entity Framework 一起使用带有代码优先的迁移文件时,它会生成 .resx 个文件 (xml),其中包含一个名为 Target 的数据字段:

  <data name="Target" xml:space="preserve">
    <value>H4sIAAAAAAAEAO ... ICAA==</value>
  </data>

该字段的格式是什么?数据末尾的 == 让人以为它是 base64,但解码后,它看起来像是二进制数据。有人知道数据的structure/format吗?

这是一个 edmx/xml 文件,经过 gzip 压缩,然后进行 base64 编码。以下应用程序将打印出给定 .resx 文件的 xml。

using System;
using System.Collections;
using System.IO;
using System.IO.Compression;
using System.Resources;
using System.Xml.Linq;

namespace ResxReader
{
    class Program
    {
        private const string ResxFilename = @"full path to your .resx file";

        public static void Main()
        {
            var reader = new ResXResourceReader(ResxFilename);
            IDictionaryEnumerator resources = reader.GetEnumerator();

            while (resources.MoveNext())
            {
                if ("Target".Equals(resources.Key))
                {
                    XDocument target = Decompress(Convert.FromBase64String(resources.Value.ToString()));

                    Console.Write(target);
                }
            }
        }

        public static XDocument Decompress(byte[] bytes)
        {

            using (var memoryStream = new MemoryStream(bytes))
            {
                using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress))
                {
                    return XDocument.Load(gzipStream);
                }
            }
        }
    }
}