MVC uses scaffolding to add controller errors: Unable to retrieve the metadata for XXX

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.