转换ADO.Net EF连接字符串是否与SQL Azure云连接字符串兼容?

时间:2009-10-09 10:47:39

标签: azure cloud azure-sql-database

情景

我编写了一个使用SQL Server数据库的Silverlight 3应用程序。我正在将应用程序移动到云(Azure平台)上。为了做到这一点,我不得不在SQL Azure上设置我的数据库。我正在使用ADO.Net实体框架来建模我的数据库。我已经在云上运行了应用程序,但我无法连接到数据库。下面是原始的localhost连接字符串,后跟无效的SQL Azure连接字符串。应用程序本身运行正常,但在尝试检索数据时失败。

原始Localhost连接字符串

     <add name="InmZenEntities" 
    connectionString="metadata=res://*/InmZenModel.csdl|res://*/InmZenModel.ssdl|res://*/InmZenModel.msl;
    provider=System.Data.SqlClient;
    provider connection string=&quot;
    Data Source=localhost;
    Initial Catalog=InmarsatZenith;
    Integrated Security=True;
    MultipleActiveResultSets=True&quot;" 
    providerName="System.Data.EntityClient" />

转换的SQL Azure连接字符串

<add name="InmZenEntities" connectionString="metadata=res://*/InmZenModel.csdl|res://*/InmZenModel.ssdl|res://*/InmZenModel.msl;
provider=System.Data.SqlClient;
provider connection string=&quot;
Server=tcp:MYSERVER.ctp.database.windows.net;
Database=InmarsatZenith;
UserID=MYUSERID;Password=MYPASSWORD;
Trusted_Connection=False;
MultipleActiveResultSets=True&quot;" 
providerName="System.Data.EntityClient" />

问题

任何人都知道SQL Azure的这个连接字符串是否正确? 非常感谢。

1 个答案:

答案 0 :(得分:1)

只需删除位;MultipleActiveResultSets=True即可。

为了您的方便,我已经为您完成了。只需复制并粘贴。

<add name="InmZenEntities" connectionString="metadata=res://*/InmZenModel.csdl|res://*/InmZenModel.ssdl|res://*/InmZenModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Server=tcp:MYSERVER.ctp.database.windows.net;Database=InmarsatZenith;UserID=MYUSERID;Password=MYPASSWORD;Trusted_Connection=False&quot;" providerName="System.Data.EntityClient" />
相关问题