Mr-Robot

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

asp.net mvc4中添加控制器时,出现【无法检索“mvc4.Models.Movie”的元数据。The connection string 'MovieDBContext' in the application's configuration file does not contain the required providerName attribute."】的问题。

解决方法

在web.config文件中配置connectionStrings不全面,因缺少providerName="System.Data.SqlClient"属性所致,添加后即可正常运行。

  <connectionStrings>

    <!--注意这里的名称要和数据库的类名称一致,即MovieDBContext.cs的类名一致-->

    <add name="MovieDBContext" connectionString="Data Source=.;Initial Catalog=MovieDB;Persist Security Info=True;User ID=sa;password=sasa" providerName="System.Data.SqlClient" />

</connectionStrings>


posted on 2015-09-02 10:29  代码养家  阅读(207)  评论(0编辑  收藏  举报