Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting "The magic number in GZip header is not correct." error using OWIN auth against Azure SQL

Nothing on Google or SO relates to this specific problem, so asking a new question. I created a brand new Asp.Net MVC Web Application with the standard user-security option. I also created an empty database in Azure.

I did nothing but change the default connection string to this:

  <connectionStrings>
    <add name="DefaultConnection" 
         connectionString="data source=mydatabase.database.windows.net;initial catalog=Feedback;persist security info=True;user id=LeaveFeedbackuser;password=mypassword;MultipleActiveResultSets=True;App=EntityFramework"
         providerName="System.Data.SqlClient" />
  </connectionStrings>

and the default connection factory to this:

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v12.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>

On attempting to register (when I would expect it to normally create the AspNetUsers and related tables) I get the following error:

The magic number in GZip header is not correct. Make sure you are passing in a GZip stream. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.InvalidDataException: The magic number in GZip header is not correct. Make sure you are passing in a GZip stream.

Source Error:

Line 153: { Line 154: var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; Line 155: var result = await UserManager.CreateAsync(user, model.Password); Line 156: if (result.Succeeded) Line 157: {

What has any of this to do with GZip and what is causing this error? This has stopped me getting OWIN working with my Azure database for several days now.

like image 279
Gone Coding Avatar asked Jan 30 '15 00:01

Gone Coding


1 Answers

I experienced a similar problem.

The Entity Framework __MigrationHistory Model column contains GZipped data. If the data in this column is corrupted then your app won't be able to unzip the data and you'll get the error.

In my case, the corruption occurred by trying to manually insert into this able.

My solution: delete corrupted __MigrationHistory rows and related DB changes and allow the app to migrate the database properly.

like image 164
Mr. Flibble Avatar answered Nov 11 '22 08:11

Mr. Flibble