Environmental vs2012
Frame MVC3
Database sqlservercompact4.0
The following errors occur:
“
---------------------------
Microsoft Visual Studio
---------------------------
Unable to retrieve metadata for "MvcMusicStore.Models.Album". Using the same dbcompiledmodel to create contexts against different types of database servers are not supported. Instead, create a separate dbcompiledmodel for each type of server being used.
---------------------------
Are you sure
---------------------------
”
Workaround: http://stackoverflow.com/questions/12410673/ Using-the-same-dbcompiledmodel-to-create-contexts-against-different-types-of-dat
“
I switched providerName="System.Data.SqlServerCe.4.0"
providerName="System.Data.SqlClient"
with, and it created the Controller and views.
OK, so switching providerName="System.Data.SqlClient"
to'll get the controller and the built, but the site won ' t run. If after using the switch to build the controller, you and then switch it back providerName="System.Data.SqlServerCe.4.0"
to, it'll then run. It's not a pretty, but it should get through the tutorial.
”
Divided into two parts
The first is to configure the database in the WebconfigproviderName="System.Data.SqlServerCe.4.0 修改成 providerName="System.Data.SqlClient" 这样就可以添加成功控制器了
Second generation controller after the Providername= "System.Data.SqlClient back to Providername=" system.data.sqlserverce.4.0 is OK
There is no second part, which means that the following error will be reported if you do not revert back:
“
[Win32Exception (0x80004005): The network path could not be found. ][sqlexception (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or could not be accessed. Verify that the instance name is correct, and that SQL Server is configured to allow remote connections. (provider:named Pipes provider, error:40-Unable to open connection to SQL Server)]
”
MVC uses scaffolding to add controller errors: Unable to retrieve the metadata for XXX