在应用程序配置文件中找不到名为“OAEntities”的连接字符串。

MVC开发中的常见错误-02-在应用程序配置文件中找不到名为“OAEntities”的连接字符串。

MVC开发中的常见错误-02-在应用程序配置文件中找不到名为“OAEntities”的连接字符串。

 

 

 

分析原因:由于Model类是数据库实体模型,通过从数据库中引用的方式添加实体,所以会自动产生一个数据库连接字符串,而程序运行到此,没有在MVC模型的App.Config中发现这个链接字符串.所以报错.

解决方法:

将Model中的APPConfig中的OAEntities

  <connectionStrings>
    <add name="OAEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=OA;user id=sa;password=sa;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
connectionStrings

相关文章:

  • 2022-01-07
  • 2021-11-12
  • 2022-02-12
  • 2022-12-23
  • 2021-08-19
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2021-07-25
  • 2021-12-08
相关资源
相似解决方案