Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Entity Framework Migrations Rebuild Target Hash
using System;
using System.IO;
using System.IO.Compression;
using System.Text;
namespace Gligoran.EntityFramework
{
class Program
{
private static string ExtractEdmx(string target)
{
var compressedBytes = Convert.FromBase64String(target);
var memoryStream = new MemoryStream(compressedBytes);
var gzip = new GZipStream(memoryStream, CompressionMode.Decompress);
var reader = new StreamReader(gzip);
return reader.ReadToEnd();
}
private static string CompressEdmx(string edmx)
{
byte[] compressed;
using (var outStream = new MemoryStream())
{
using (var gzipStream = new GZipStream(outStream, CompressionMode.Compress))
using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(edmx)))
memoryStream.CopyTo(gzipStream);
compressed = outStream.ToArray();
}
return Convert.ToBase64String(compressed);
}
}
}
using Gligoran.EntityFramework
namespace Gligoran
{
class Program
{
static void Main(string[] args)
{
var edmx = ExtractEdmx("<paste you target hash here>");
var base64 = CompressEdmx(edmx);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment