开发者

Connecting to a SQL Server using Entity Framework 4

So on my development machine I have SQL Server Express and Visual Studio installed. I finished creating the application and everythings working. Here is the connection string in the App.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="ColegioDBEntities"
         connectionString="metadata=res://*/Repositories.ColegioModel.csdl|res://*/Repositories.ColegioModel.ssdl|res://*/Repositories.ColegioModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;Initial Catalog=ColegioDB;Integrated Security=True;MultipleActiveResultSets=True&quot;"
         providerName="System.Data.EntityClient" />
  </connectionStrings>

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" />
  </startup>
</config开发者_运维问答uration>

I created an installation project and want to install the application on a Virtual Machine (to simulate deployment conditions) which is on the same network as where the SQL Server Express is installed. What would the connection string be? Like, 192.168.2.102/SQLExpress?

Any ideas?


surely the IP address or host name will be needed then the instance name of SQL Express. Consider that by default SQL Express is installed with tcp and named pipes disabled so you have to enable those facilities in the configuration manager before you could access it remotely from another machine.


The sql connection string is part of the "connectionString" attribute and is encoded as a substring with masked quotes:

provider connection string=&quot;Data Source=.\SQLEXPRESS;Initial Catalog=ColegioDB;Integrated Security=True;MultipleActiveResultSets=True&quot;

so the config for your ip adress must look like:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="ColegioDBEntities"
         connectionString="metadata=res://*/Repositories.ColegioModel.csdl|res://*/Repositories.ColegioModel.ssdl|res://*/Repositories.ColegioModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=192.168.2.102\SQLEXPRESS;Initial Catalog=ColegioDB;Integrated Security=True;MultipleActiveResultSets=True&quot;"
         providerName="System.Data.EntityClient" />
  </connectionStrings>

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" />
  </startup>
</configuration>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜