无法检索元数据 - MVC 应用程序 [英] Unable to retrieve metadata - MVC application
问题描述
我正在关注 其中解决方案是通过更改 providerName 来提供的.但就我而言,它已经是 System.Data.SqlClient.以下是我的 connectionStrings :
<add name="DefaultConnection" connectionString="Data Source=.SQLEXPRESS;Initial Catalog=aspnet-MvcApplication-20130708120940;Integrated Security=SSPI" providerName="System.Data.SqlClient"/><add name="MovieDBContext" connectionString="Data Source=(LocalDB)v11.0;AttachDbFilename=|DataDirectory|Movies.mdf;Integrated Security=True" providerName="System.Data.SqlClient"/></connectionStrings>
错误消息说 AttachDbFilename
的值无效,它是 MovieDbContext
连接字符串的一部分.
连接字符串当前显示此 AttachDbFilename=|DataDirectory|Movies.mdf
,因此 App_Data
文件夹中现在似乎缺少 mdf 文件.
I was following this to create a simple MVC application. After creating the model, when I tried to add controller, I got the following error :
Unable to retrieve metadata for "MvcApplication.Models.Movie". Invalid value for key "attachdbfilename".
Can someone tell why I am getting this error.
Update : I saw this wherein solution is provided by changing the providerName. But in my case it is already System.Data.SqlClient. Following are my connectionStrings :
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.SQLEXPRESS;Initial Catalog=aspnet-MvcApplication-20130708120940;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
<add name="MovieDBContext" connectionString="Data Source=(LocalDB)v11.0;AttachDbFilename=|DataDirectory|Movies.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
The error message is saying invalid value for AttachDbFilename
which is part of your MovieDbContext
connection string.
The connection string currently shows this AttachDbFilename=|DataDirectory|Movies.mdf
so it appears the mdf file is now missing from the App_Data
folder.
这篇关于无法检索元数据 - MVC 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!