.net Azure SQL数据库在本地运行时工作,但在发布到Azure时不工作

.net Azure SQL数据库在本地运行时工作,但在发布到Azure时不工作,.net,azure,ef-code-first,asp.net-web-api,entity-framework-5,.net,Azure,Ef Code First,Asp.net Web Api,Entity Framework 5,我的问题与诸如此类的问题非常相似,但并不完全相同 当我在本地连接到azure数据库时,它运行得非常好。但当我部署到Azure时,它似乎无法连接到数据库。我首先使用EntityFramework5代码,并且在EF5引用中还设置了copyLocal:true 以下是我的连接字符串: <add name="api" connectionString=" Server=tcp:[hidden].database.windows.net,1433;Database=API;

我的问题与诸如此类的问题非常相似,但并不完全相同

当我在本地连接到azure数据库时,它运行得非常好。但当我部署到Azure时,它似乎无法连接到数据库。我首先使用EntityFramework5代码,并且在EF5引用中还设置了copyLocal: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"/>
在读取stacktrace时,可以肯定的是,问题在于我无法初始化成员数据库。这一定是Azure部署问题,但我似乎无法解决

编辑:

API数据库现在正在工作,但成员身份给出了相同的错误。我将网站缩放为保留而不是共享。不知道这是否会有任何影响

固定:


这太奇怪了。。突然,网站与这两个数据库都建立了连接。未执行任何其他操作,将服务器从共享更改为保留。

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

检查在Windows Azure portal上制定的IP规则,并确保您当前的IP地址在允许访问在Windows Azure上运行的数据库的范围内假设您已将SQL Azure防火墙设置为允许Windows Azure服务?是的,我已将其设置为允许Windows Azure服务:)我已设置。为了测试,我甚至添加了范围为0.0.0.0-255.255.255.255的ip地址。仍然不起作用:(参考上述评论:)
    <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.