尝试发布 Web 应用程序时应用程序出现服务器错误。对象名称无效 'dbo.Employees'
Server Error in Application when trying to publish web app. Invalid object name 'dbo.Employees'
我正在尝试使用 Azure 的数据库发布我的 Web 应用程序,但我 运行 遇到此错误:
Invalid object name 'dbo.Employee'.
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.Employee'.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
这是我的连接字符串:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-HolidayTracker-20190122013056.mdf;Initial Catalog=aspnet-HolidayTracker-20190122013056;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="LotusWorksEntities" connectionString="metadata=res://*/Models.HolidayTrackerModel.csdl|res://*/Models.HolidayTrackerModel.ssdl|res://*/Models.HolidayTrackerModel.msl;provider=System.Data.SqlClient;provider connection string="data source=DESKTOP-LAKNQGQ\CONORSQL;initial catalog=LotusWorks;user id=sa;password={"mypassword"};MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
我不确定在发布时是否正确使用了这些,因为这是我的第一个网络应用程序。它确实已发布,但每当我使用使用数据库的页面时,我都会收到错误消息。
Exception Details: System.Data.SqlClient.SqlException: Invalid object name
'dbo.Employee'.
此错误意味着 EF 使用了一个名为 dbo.Employee 的对象(很可能是 table),该对象在数据库中不存在。
检查您的数据库并验证 table 是否存在,或者您是否应该使用不同的 table 名称。
另外,根据您的描述,您提供的连接字符串是所有本地Sql数据库。由于要发布到azure并查看使用数据库的页面,需要使用AzureSql数据库提供数据。这是一个tutorial你可以参考。
在设置 Azure sql 数据库后,select Use this connection string at runtime(update destination web.config)
选项,因此它将使用 azure sql db 连接字符串。
我正在尝试使用 Azure 的数据库发布我的 Web 应用程序,但我 运行 遇到此错误:
Invalid object name 'dbo.Employee'.
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.Employee'.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
这是我的连接字符串:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-HolidayTracker-20190122013056.mdf;Initial Catalog=aspnet-HolidayTracker-20190122013056;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="LotusWorksEntities" connectionString="metadata=res://*/Models.HolidayTrackerModel.csdl|res://*/Models.HolidayTrackerModel.ssdl|res://*/Models.HolidayTrackerModel.msl;provider=System.Data.SqlClient;provider connection string="data source=DESKTOP-LAKNQGQ\CONORSQL;initial catalog=LotusWorks;user id=sa;password={"mypassword"};MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
我不确定在发布时是否正确使用了这些,因为这是我的第一个网络应用程序。它确实已发布,但每当我使用使用数据库的页面时,我都会收到错误消息。
Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'dbo.Employee'.
此错误意味着 EF 使用了一个名为 dbo.Employee 的对象(很可能是 table),该对象在数据库中不存在。
检查您的数据库并验证 table 是否存在,或者您是否应该使用不同的 table 名称。
另外,根据您的描述,您提供的连接字符串是所有本地Sql数据库。由于要发布到azure并查看使用数据库的页面,需要使用AzureSql数据库提供数据。这是一个tutorial你可以参考。
在设置 Azure sql 数据库后,select Use this connection string at runtime(update destination web.config)
选项,因此它将使用 azure sql db 连接字符串。