c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
asp.net MVC

Unable to retrieve metadata for ‘models.classname’. unable to cast object of type System.Data.Entity.Core.Objects.ObjectContext to type System.Data.Objects.ObjectContext.

| | webconfig

Entity framework 6 or above version is not supported for asp.net MVC. So we need to uninstall it by using Package manager console.

Uninstall-Package EntityFramework –Version 6.0.0

If it is uninstalled then install entity framework 5.

If you are unable uninstall then I recommended you to delete the following entity framework version 6.0.0 reference from package.config.

<package id="EntityFramework" version="6.0.0" targetFramework="net45" />

Again install entity framework 5 by running the following command in the Package Manager Console

 

PM> Install-Package EntityFramework –Version 5.0.0.0