在 entity framework 连接字符串中转义 "
Escape " in entity framework connectionstring
使用 SQL Anywhere 17 我们需要在连接后进行身份验证,我将其设置为 InitString,当我执行 SAConnection.Connect
时效果很好
<add key="connectionString" value="UID=dba;PWD=***;Host=10.10.10.10:2638;InitString='SET TEMPORARY OPTION CONNECTION_AUTHENTICATION="Company=Quick Systems AS;Application=EQ Timing;Signature=xxxx...xxx"'"/>
但是当使用 Entity Framework 这个字符串已经被编码了一次:
<add name="TimingConnection" connectionString="metadata=res://*/Timing.csdl|res://*/Timing.ssdl|res://*/Timing.msl;provider=Sap.Data.SQLAnywhere;provider connection string="UserID=dba;Password=sql;Host=10.10.10.10"" providerName="System.Data.EntityClient"/>
如何添加身份验证InitString
<add name="TimingConnection" connectionString="metadata=res://*/Timing.csdl|res://*/Timing.ssdl|res://*/Timing.msl;provider=Sap.Data.SQLAnywhere;provider connection string="UserID=dba;Password=sql;Host=10.10.10.10;InitString='SET TEMPORARY OPTION CONNECTION_AUTHENTICATION="Company=Quick Systems AS;Application=EQ Timing;Signature=xxx...xxx"'"" providerName="System.Data.EntityClient"/>
我得到的错误是初始化字符串的格式不符合从索引 98 开始的规范。
为了在连接字符串中进行内部转义,我需要将 "
加倍,所以它是 ""
<add name="TimingConnection" connectionString="metadata=res://*/Timing.csdl|res://*/Timing.ssdl|res://*/Timing.msl;provider=Sap.Data.SQLAnywhere;provider connection string="";UserID=dba;Password=sql;Host=10.10.10.10;InitString='SET TEMPORARY OPTION CONNECTION_AUTHENTICATION="Company=Quick Systems AS;Application=EQ Timing;Signature=xxx...xxx""'"" providerName="System.Data.EntityClient"/>
使用 SQL Anywhere 17 我们需要在连接后进行身份验证,我将其设置为 InitString,当我执行 SAConnection.Connect
时效果很好<add key="connectionString" value="UID=dba;PWD=***;Host=10.10.10.10:2638;InitString='SET TEMPORARY OPTION CONNECTION_AUTHENTICATION="Company=Quick Systems AS;Application=EQ Timing;Signature=xxxx...xxx"'"/>
但是当使用 Entity Framework 这个字符串已经被编码了一次:
<add name="TimingConnection" connectionString="metadata=res://*/Timing.csdl|res://*/Timing.ssdl|res://*/Timing.msl;provider=Sap.Data.SQLAnywhere;provider connection string="UserID=dba;Password=sql;Host=10.10.10.10"" providerName="System.Data.EntityClient"/>
如何添加身份验证InitString
<add name="TimingConnection" connectionString="metadata=res://*/Timing.csdl|res://*/Timing.ssdl|res://*/Timing.msl;provider=Sap.Data.SQLAnywhere;provider connection string="UserID=dba;Password=sql;Host=10.10.10.10;InitString='SET TEMPORARY OPTION CONNECTION_AUTHENTICATION="Company=Quick Systems AS;Application=EQ Timing;Signature=xxx...xxx"'"" providerName="System.Data.EntityClient"/>
我得到的错误是初始化字符串的格式不符合从索引 98 开始的规范。
为了在连接字符串中进行内部转义,我需要将 "
加倍,所以它是 ""
<add name="TimingConnection" connectionString="metadata=res://*/Timing.csdl|res://*/Timing.ssdl|res://*/Timing.msl;provider=Sap.Data.SQLAnywhere;provider connection string="";UserID=dba;Password=sql;Host=10.10.10.10;InitString='SET TEMPORARY OPTION CONNECTION_AUTHENTICATION="Company=Quick Systems AS;Application=EQ Timing;Signature=xxx...xxx""'"" providerName="System.Data.EntityClient"/>