【发布时间】:2018-01-17 08:52:51
【问题描述】:
我最近订阅了 Azure 免费试用版,目前正在尝试发布我的网站。
但是,当我发布我的网站时,我遇到了以下错误:
[NullReferenceException: Object reference not set to an instance of an object.]
MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken(DbConnection connection) +56
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +276
System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) +27
System.Data.Entity.Infrastructure.<>c__DisplayClass1.<ResolveManifestToken>b__0(Tuple`3 k) +32
System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +72
System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection) +251
System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) +56
System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +43
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +62
System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +123
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +610
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +53
System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15
System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +38
当我使用远程数据库的连接字符串在本地运行它时,它工作正常,但一旦我发布它就不起作用。
我的连接字符串如下所示:
<add name="DefaultConnection" connectionString="user id=****;password=****;persistsecurityinfo=False;server=**** ;database=iprospect_tools" providerName="MySql.Data.MySqlClient" />
<add name="ToolsEntities" connectionString="metadata=res://*/ToolsModel.csdl|res://*/ToolsModel.ssdl|res://*/ToolsModel.msl;provider=MySql.Data.MySqlClient;provider connection string="user id=****;password=****;persistsecurityinfo=False;server=****;database=tools"" providerName="System.Data.EntityClient" />
当我远程调试我的应用程序时,这是错误评估:
知道是什么导致了这个错误吗?
【问题讨论】:
-
您的数据库和网站在 Azure 中托管在哪里(哪个服务)?您是否能够在 azure 中从您的实例 ping 数据库。
-
我的网站托管为 Web 应用程序,我的数据库托管为 MySQL 数据库。我不确定从 Azure 中的实例 ping 数据库的位置 - 你能告诉我在哪里可以做到吗?
-
您可以通过 kudu 使用命令控制台。要访问 kudu,请浏览sitename.scm.azurewebsites.net/DebugConsole。在这里,您可以使用 tcpping.exe 在特定端口上 ping 主机名。
tcpping hostname:port -
将站点名称替换为您的 Web 应用程序的名称。
-
我可以成功 ping 我的数据库。
标签: c# mysql entity-framework azure azure-web-app-service