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

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

问题描述

我下面<一个href=\"http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/accessing-your-models-data-from-a-controller\"相对=nofollow> 这个 创建一个简单的 MVC 应用程序。创建模型后,当我试图添加控制器,我得到了以下错误:

无法检索元数据MvcApplication.Models.Movie。关键attachdbfilename无效的价值。

谁能告诉我为什么我收到此错误。

更新:我看了<一个href=\"http://stackoverflow.com/questions/15445786/add-controller-error-unable-to-retrieve-metadata\">this其中溶液是通过改变的providerName提供。但在我的情况下,它已经 System.Data.SqlClient的。以下是我是connectionStrings:

 &LT;&是connectionStrings GT;
    &LT;添加名称=DefaultConnection的connectionString =数据源= \\ SQLEX $ P $干燥综合征;初始目录= ASPNET-MvcApplication-20130708120940;集成安全性= SSPI的providerName =System.Data.SqlClient的/&GT;
    &LT;添加名称=MovieDBContext的connectionString =数据源=(的LocalDB)\\ V11.0; AttachDbFilename = | DataDirectory目录| \\ Movies.mdf;集成安全性=真的providerName =System.Data.SqlClient的/&GT;
  &LT; /&是connectionStrings GT;


解决方案

该错误消息说,为 AttachDbFilename 无效值它属于你的 MovieDbContext 连接字符串。

连接字符串目前显示该 AttachDbFilename = | DataDirectory目录| \\ Movies.mdf 所以会出现mdf文件正在从失踪的App_Data 文件夹中。

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天全站免登陆