Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7782141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:26:55+00:00 2026-06-01T19:26:55+00:00

I am trying to retrieve product name and its ids as NameID object from

  • 0

I am trying to retrieve product name and its ids as NameID object from EntityFramework using WebAPI. code for which is as following.

public class ProductController : ApiController
{
    protected MainDataContext db = new MainDataContext();
    // GET /api/values
    public IQueryable<NameID> Get()
    {
        return db.Products.Select(x=>new NameID{ ID=x.ID,Name=x.Name }).AsQueryable();
    }

    // GET /api/values/5
    public NameID Get(long id)
    {
        var result = db.Products.Select(x=>new NameID{ ID=x.ID,Name=x.Name }).SingleOrDefault(x => x.ID == id);
        if (id == 0 || result == null)
            throw new HttpResponseException(HttpStatusCode.NotFound); 
        return result;
    }

}
public class NameID {
    public long ID {get;set;}
    public string Name {get;set;}
}

It throws error as following

The magic number in GZip header is not correct.
Make sure you are passing in a GZip stream.

at System.IO.Compression.GZipDecoder.ReadHeader(InputBuffer input) 
at System.IO.Compression.Inflater.Decode() 
at System.IO.Compression.Inflater.Inflate(Byte[] bytes, Int32 offset, Int32 length) 
at System.IO.Compression.DeflateStream.Read(Byte[] array, Int32 offset, Int32 count) 
at System.IO.Compression.GZipStream.Read(Byte[] array, Int32 offset, Int32 count) 
at System.Xml.XmlTextReaderImpl.InitStreamInput(Uri baseUri, String baseUriStr, Stream stream, Byte[] bytes, Int32 byteCount, Encoding encoding) 
at System.Xml.XmlTextReaderImpl..ctor(Stream stream, Byte[] bytes, Int32 byteCount, XmlReaderSettings settings, Uri baseUri, String baseUriStr, XmlParserContext context, Boolean closeInput) 
at System.Xml.XmlReaderSettings.CreateReader(Stream input, Uri baseUri, String baseUriString, XmlParserContext inputContext) 
at System.Xml.XmlReader.Create(Stream input, XmlReaderSettings settings, String baseUri) 
at System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options) 
at System.Data.Entity.Migrations.Edm.ModelCompressor.Decompress(Byte[] bytes) 
at System.Data.Entity.Migrations.History.HistoryRepository.GetLastModel(String& migrationId) 
at System.Data.Entity.Migrations.History.HistoryRepository.GetLastModel() 
at System.Data.Entity.Internal.InternalContext.QueryForModel() 
at System.Data.Entity.Internal.ModelCompatibilityChecker.CompatibleWithModel(InternalContext internalContext, ModelHashCalculator modelHashCalculator, Boolean throwIfNoMetadata) 
at System.Data.Entity.Internal.InternalContext.CompatibleWithModel(Boolean throwIfNoMetadata) 
at System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context) 
at System.Data.Entity.Internal.InternalContext.<>c__DisplayClass8.<PerformDatabaseInitialization>b__6() 
at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) 
at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() 
at System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c) 
at System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) 
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) 
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() 
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) 
at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() 
at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() 
at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() 
at System.Linq.Queryable.Select[TSource,TResult](IQueryable`1 source, Expression`1 selector) 
at ProductAPI.Controllers.ProductController.Get() in D:\Demo\ProductAPI\Controllers\ProductController.cs:line 24 
at lambda_method(Closure , Object , Object[] ) 
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) 
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.Execute(HttpControllerContext controllerContext, IDictionary`2 arguments) 
at System.Web.Http.Controllers.ApiControllerActionInvoker.<>c__DisplayClass2.<InvokeActionAsync>b__0() 
at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:26:57+00:00Added an answer on June 1, 2026 at 7:26 pm

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying retrieve user name from the code through graph api, the below
I am trying to retrieve some data from an API using CURL request. Is
I'm receiving the following error with this page while trying to retrieve information from
In my block code I am trying to programmatically retrieve a list of products
Iam trying to retrieve data from mysql database into stylesheet.php but it is not
//hi i am trying to retrieve the data from database and display in my
I am trying to retrieve the upcoming birthdays from Facebook via the FQL Is
I'm trying to retrieve activity data from webservice. Here's my webservice codes. public string
I'm trying to retrieve email using IMAP that's less than a certain number of
I'm trying to export ALL records from a Visual Collection to excel. My code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.