Unable to retrieve metadata for 'MusicStore.Models.Album'. Using the same DbCompiledModel to create context against different types of database servers is not supported. Instead, create a separate DbCompiledModel for each type of server being used.
You will get this error in the step by step tutorial (on page here) provided by Microsoft that starts from here.
If you look in your solution you will find 'SQL Server CE' database is being used and to which the application was somehow unable to connect and thus this message comes up.
Once you update the connectionString to use a regular 'SQL Server' database will fix this titled issue.
How to fix?
In Part 4 of this step by step turorial, you probably have added following code in you connectionString:
Now, delete above chunk of codes and run the application and try to navigate to ‘Store’ controller, this will automatically create the new and regular ‘SQL Server’ Database for your project and will also seed some dummy data from a file ‘SampleData.cs’, you will find this in ‘Model’ folder.
And now, you are ready to go further in that step by step tutorial.
I hope this fix will help you. Thanks.
i too got this error....thank u very much ur solution helped me in fixing itReplyDelete
Thanks for your postReplyDelete
Thanks for your helpingReplyDelete
thanks alot...but one thing that i have noticed is you will need that code which have been deleted after the database has been added. so i think you should better keep it safe and put it later in config file again.ReplyDelete
That worked. Thank you sir!ReplyDelete
Thanks a lot bro...... It will workReplyDelete
A lot new information found until found this topic. Thanks a lot.ReplyDelete
very useful, thanks so much!ReplyDelete
It worked. Thank for sharing.ReplyDelete
it helped me..thankuReplyDelete
YES..Absolutely do not change ANYTHING, at all, in anyway in the web.config files contents and everything works great..must of course add the new controller's name to the http:\\localxxx\newcontrollersname call.ReplyDelete
The "DefautlConnection" that comes with the MVC autobuild does not create a db but works with a log file to create the movies.ReplyDelete
This code worked for me creating .mdf and .ldf files in the App_Data folder under the project files.….now will that translate to SQL on hosting web???
connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=MVCSqlTest;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\MVCSqlTest.mdf"
Thanks Abhi, it's working for me. :)ReplyDelete
Thank you man , it worksReplyDelete
Thanks Abhimanyu !!! Your suggestion resolved the issue.ReplyDelete
It works.. thanks...ReplyDelete
Uninstalling Entity Framework 6.0 and Installing Entity Framework 5.0 solved this error.ReplyDelete
In NuGet Package Manager Console I ran below command to solve this issue.
Uninstall Entity Framework 6.0 using below command:
UnInstall-Package EntityFramework.SqlServerCompact UnInstall-Package EntityFramework
Then install Entity Framework 5.0 using below :
Install-Package EntityFramework -Version 5.0.0
Install-Package EntityFramework.SqlServerCompact -Version 4.3.6