Reputation: 7444
When publishing my site to azure, an additional connection string is being added with the original name appended with _datapublish.
How can I stop this from happening? I'm happy to manage my connection strings using web.config transforms.
<connectionStrings>
<add name="MyAppContext" connectionString="Server=tcp:sdfdfsfsdf.database.windows.net,1433;Database=MyApp;User ID=xxxxxxx;Password=xxxxxxx;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.SqlClient" />
<add name="StorageConnectionString" connectionString="DefaultEndpointsProtocol=http;AccountName=MyApp;AccountKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
<add name="MyAppContext_DatabasePublish" connectionString="MyAppContext_DatabasePublish.ConnetionString" providerName="System.Data.SqlClient" />
</connectionStrings>
I now get the following error on the live site:
Format of the initialization string does not conform to specification starting at index 0.
When comparing the released file I notice that this is also added under the entityFramework section:
<contexts>
<context type="MyApp.Data.MyAppContext, MyApp.Data">
<databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[MyApp.Data.MyAppContext, MyApp.Data], [MyApp.Data.Migrations.Configuration, MyApp.Data]], EntityFramework, PublicKeyToken=b77a5c561934e089">
<parameters>
<parameter value="MyAppContext_DatabasePublish" />
</parameters>
</databaseInitializer>
</context>
</contexts>
Upvotes: 2
Views: 850
Reputation: 9378
This second connection string is automatically injected if the "Apply Code First migrations" (VS 2012) or "Execute Code First Migrations" (VS 2013) checkbox is checked in the deployment wizard:
See this answer for more details
Upvotes: 1
Reputation: 7444
Found the answer here...
Publish ASP.NET MVC 5 website to Windows Azure
The datapublish stuff is still in the web.config but no exception is thrown when I run the app anymore. At least there is no more need to edit the file every time after deploying.
Upvotes: 1