2

I'm trying to run existing WCF service as a stateful reliable service. The WCF service uses EF4's object context API that requires connection string in the form of

<connectionStrings>
  <add name="myEntities" connectionString="metadata=res://*/MyEntities.csdl|res://*/MyEntities.ssdl|res://*/MyEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=My-PC;Initial Catalog=MyDatabase;User=sa;Password=password;Integrated Security=false&quot;" providerName="System.Data.SqlClient" /> 
</connectionStrings>

Previously the service could easily find this connection string from config file by referencing to its name. Now in Service Fabric I have to specify any custom configuration in Settings.xml file under Config folder of my package that only seems to support key values like this:

<Section Name="ConnectionStrings">
    <Parameter Name="Entities" Value="metadata=res://*/MyEntities.csdl|res://*/MyEntities.ssdl|res://*/MyEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=My-PC;Initial Catalog=MyDatabase;User=sa;Password=password;Integrated Security=false&quot;"/>
</Section>

How do I specify the provider name here?

Saad
  • 198
  • 2
  • 12
  • You don't. You just read the connecting string and pass it to the object context constructor. – Peter Bons Jun 02 '18 at 09:33
  • I get the Argument Exception `Keyword not supported: 'data source'`I searched for it and I have to specify provider name to resolve it. – Saad Jun 02 '18 at 10:40
  • 1
    You can set tet manually, see https://stackoverflow.com/questions/23902496/how-to-set-connection-string-with-entity-framework – Peter Bons Jun 02 '18 at 11:19
  • It worked :) So there is no direct way to specify it in the configuration file? Does SF ignore the .config files of the executable project and use only Settings.xml? As I have other things in .config files as well like logging configurations etc. – Saad Jun 02 '18 at 11:49

0 Answers0