The magic number in GZip header is not correct. Make sure you are passing in a GZip stream
The stack trace seems to indicate the there is a problem reading the Entity Framework model metadata from the database.
HistoryRepository.GetLastModel
calls ModelCompressor.Decompress
that uses XDocument.Load
to read some XML from a GZipStream
. This fails and the model metadata in the database is most likely corrupted.
You can try to recreate the database to get around this problem.
Its a little late and there is already an accepted answer, which will work. But, if you already have a working database and do not want to refresh the database, then you can call Database.SetInitializer
with null in Global.asax's application_start function. This will not looking for the __migrationhistory
table that contains the corrupt data.
No way to recreate the database for me and I am already using Database.SetInitializer
with null
.
Fortunately, I have an up-to-date __MigrationHistory
table on another database and I used this Sql query to set the correct value in the target database :
INSERT INTO TargetDbName.dbo.__MigrationHistory (MigrationId, Model, ProductVersion)
SELECT MigrationId, Model, ProductVersion
FROM SourceDbName.dbo.__MigrationHistory
WHERE MigrationId = 'YYYYMMDDHHMMSSFFF_LastMigration'