【问题标题】:Server Error in Application. Invalid object name 'dbo.Categories'应用程序中的服务器错误。无效的对象名称“dbo.Categories”
【发布时间】:2012-12-11 05:59:09
【问题描述】:

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

“/samarth”应用程序中的服务器错误。 无效的对象名称“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 提供程序一起使用,或者无效。

【问题讨论】:

  • 您问“连接字符串有问题吗?” - 但你还没有展示出来!
  • 查看this 以获得演示。
  • 这是一个非常明确的错误:“无效的对象名称'dbo.Categories'。”您的权限错误,您指向错误的数据库,并且您没有正确部署目标数据库。修复它。
  • 我想我在处理连接字符串时遇到了麻烦。
  • -1 投票不能解决我的问题,甚至没有帮助。我也反对您为帮助和理解问题所做的努力。

标签: asp.net visual-studio-2010 entity-framework c#-4.0


【解决方案1】:

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

【讨论】:

  • 我已经上传了相同的数据库在服务器上使用。 dbo.Categories 存在。
  • 如果您有正确的数据库服务器和数据库,请检查连接字符串?
  • 我的托管服务提供商说我应该把它作为我的连接字符串:"Data Source=.\SQLExpress;Persist Security Info=True;Integrated Security=SSPI;Initial Catalog=YourUserId_DatabaseName"
  • 但是如果我使用这些连接字符串,CommerceEntities连接字符串中的元数据信息将会丢失。请指导。
  • 你能像访问其他表或存储过程一样访问其他数据库对象吗?您需要确保数据库中有 dbo.Categories,您可能需要向 Service Provider 寻求帮助
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-05
  • 1970-01-01
  • 1970-01-01
  • 2017-03-07
  • 1970-01-01
相关资源
最近更新 更多