Monday, 24 February 2014

Web.config changing when publishing application - how to avoid it?

I have MVC website, that I deployed to Azure. The application uses EF Code First. 

After deployment, these lines were added to web.config:

  <connectionStrings>
    <add name="LoremIpsum.LoremContext" 
         connectionString="LoremIpsum.LoremContext_ConnectionString" 
         providerName="System.Data.SqlClient" />
  </connectionStrings>

This caused this error:

Format of the initialization string does not conform to specification starting at index 0.

I solved this by going to my Publish Profile (the .pubxml file) and deleted following lines:

  <ItemGroup>
    <MSDeployParameterValue Include="$(DeployParameterPrefix)LoremIpsum.LoremContext-Web.config Connection String">
      <ParameterValue>... my actual connection string ...</ParameterValue>
    </MSDeployParameterValue>
  </ItemGroup>
  <ItemGroup>
    <_ConnectionStringsToInsert Include="LoremIpsum.LoremContext" />
  </ItemGroup>

No comments:

Post a Comment