3

我的问题与SO上的this问题非常相似,但不完全相同。Azure SQL数据库在本地运行时工作,但未在发布到Azure时工作

当我在本地连接到我的天蓝色数据库时,它运行完美。但是当我部署到Azure时,似乎无法连接到数据库。我首先使用了Entity Framework 5代码,并且我还在EF 5参考中设置了copy local:true。

这是我的连接字符串:

<add name="api" connectionString=" 
    Server=tcp:[hidden].database.windows.net,1433;Database=API; 
    User ID=[hidden]@[hidden]; 
    Password=[hidden];Trusted_Connection=False; 
    Encrypt=True;Connection Timeout=30; 
    PersistSecurityInfo=True;" providerName="System.Data.SqlClient" /> 

    <add name="Membership" connectionString=" 
    Server=tcp:[hidden].database.windows.net,1433; 
    Database=Membership;User ID=[hidden]@[hidden]; 
    Password=[hidden];Trusted_Connection=False; 
    Encrypt=True;Connection Timeout=30; 
    PersistSecurityInfo=True;" providerName="System.Data.SqlClient"/> 

我在web.config文件中添加

<customErrors mode="Off"/> 

所以我可以看到堆栈跟踪,这些都是我得到的例外:

[TargetInvocationException: Exception has been thrown by the target of an invocation.] 
[InvalidOperationException: The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588] 
[ProviderIncompatibleException: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. 

当读取堆栈跟踪时,肯定会问题是我无法初始化成员资格数据库。这必须是一个Azure的部署问题,但我似乎无法推测出来..

编辑:

的API,数据库现在的工作,但会员给出了同样的错误。我缩放了网站而不是共享。不知道这是否会产生任何影响。

FIXED:

嗯,这是才怪..突然,网站有两种数据库连接。没有做任何其他更改服务器从共享保留..

+0

我假设你已经设置SQL Azure的防火墙以允许Windows的范围内Azure服务? – JuneT 2013-03-07 15:21:51

+0

是的,我已经设置它允许Windows Azure服务:) – 2013-03-07 15:31:08

回答

0

请确保您的IP地址在数据库允许的IP地址列表中。

+0

参考上面的评论:) – 2013-03-08 13:09:53

3

检查IP规则上的Windows Azure门户网站制作,并确保您的IP地址是允许你访问数据库运行在Windows Azure上

+0

我做到了。为了测试,我甚至添加了从0.0.0.0-255.255.255.255范围内的IP地址。仍然没有工作:( – 2013-03-08 13:09:35

相关问题