Unable to retrieve metadata for 'MVCMusicStore.Models.Album'. Unable to cast object of type 'System.Data.Entity.Core.Objects.ObjectContext' to type 'System.Data.Objects.ObjectContext'

Nov 15, 2013 at 9:33 AM
While Creating the StoreManager Controller..this error is occuring... plz help..
Mar 27, 2014 at 7:53 AM
I have the same error as I clicked Add to create StoreManagerController. I have commented out the connectionString but get the same error. I would appreciate any suggestion to the solution of this problem. Thanks, Nkokwuc
Apr 28, 2014 at 11:14 AM
Edited Apr 28, 2014 at 11:14 AM
its the connectionString 's problem. just replace the said ConnString with the default one, create the controller, and undo the replace.
replace the
<add name="MusicStoreEntities"
 connectionString="Data Source=|DataDirectory|MvcMusicStore.sdf"

with somthing similar this one:
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-MvcMusicStore-20140428000250;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-MvcMusicStore-20140428000250.mdf" />

or something similar.its the Provider 's problem I think
Jul 15, 2014 at 7:37 PM
Edited Jul 16, 2014 at 1:09 AM
Oh boy. VisualStudio2010/ MVC4 /EF6.1.1

Chapter 5 - I am unable to create the StoreManagerController successfully(at all). I have tried ALL the posted fixes; Primarily to - Delete/comment out/create a dummy Connection string and/or reloading Nuget package via command line -
PM > Install-Package EntityFramework
'EntityFramework 6.1.1' already installed.
MvcMusicStore already has a reference to 'EntityFramework 6.1.1'.

Anybody else got any suggestions ?
Can ya just manually create(copy) it from zip file and ? add any necessary webconfigs ? What would be missing, where's the real problem... Thanks
Jul 20, 2014 at 3:35 PM
Hi Edwards,
The solution is simple:
  1. Make sure your connection String is okay
  2. Create StoreManagerController before you install NuGet Packages.... (if you need to install any). If you have installed any package you might likely repeat the process.
    Hope this will help