无法检索元数据 - MVC 应用程序 [英] Unable to retrieve metadata - MVC application

查看:20
本文介绍了无法检索元数据 - MVC 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 其中解决方案是通过更改 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆