1

我正在使用 ASP.NET 和实体框架 c# 开发在线购物 Web 应用程序。问题是当我在本地 ASP.NET 开发服务器上测试我的应用程序时,它运行良好,但是当我托管网站时,它给出了以下错误:

“/samath”应用程序中的服务器错误。无效的对象名称“dbo.Categories”。

Description: An unhandled exception occurred during the execution of the current web 

request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'dbo.Categories'.

连接字符串有问题吗?

<connectionStrings>
        <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
        <add name="CommerceEntities" connectionString="metadata=res://*/Data_Access.EDM_Commerce.csdl|res://*/Data_Access.EDM_Commerce.ssdl|res://*/Data_Access.EDM_Commerce.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Commerce.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>
    </connectionStrings>

得到这个错误:

指定的命名连接在配置中未找到,不打算与 EntityClient 提供程序一起使用,或者无效。

4

1 回答 1

2

你得到System.Data.SqlClient.SqlException这意味着你连接到数据库,因为这个异常是由数据库返回的,很可能你没有在服务器上更新数据库。检查您是否有dbo.Categories exists正在连接的数据库。您可以在此处阅读有关连接字符串的更多信息

于 2012-12-11T06:00:46.777 回答