I have an ASP MVC 5 app with code first migrations enabled. Whenever I publish it to a server, it adds an extra connection string to the Web.Config file along with a "parameter" element, and it breaks the site until I replace it. It looks like:
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
<contexts>
<context type="MyApp.DataLayer.MyContext, MyApp">
<databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[MyApp.DataLayer.MyContext, MyApp], [MyApp.Migrations.Configuration, MyApp]], EntityFramework, PublicKeyToken=b77a5c561934e089">
<parameters>
<parameter value="MyContext_DatabasePublish" />
</parameters>
</databaseInitializer>
</context>
</contexts>
</entityFramework>
<connectionStrings>
<add name="MyContext" connectionString="Data Source=SQLServerName;Initial Catalog=MyDB;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
<add name="MyContext_DatabasePublish" connectionString="MyContext_DatabasePublish.ConnetionString" providerName="System.Data.SqlClient" />
</connectionStrings>
I presume that extra connection string is for the database migrations, is that right? All I have to do to get things working is replace the connection string with the one above it, so replace MyContext_DatabasePublish.ConnetionString with Data Source=SQLServerName;Initial Catalog=MyDB;Integrated Security=SSPI for example.
First, is that connection string even needed? This is all in dev, and my migrations were all done from my local machine.
If it is needed, is there a way to keep it from coming in as MyContext_DatabasePublish.ConnetionString and instead come in as the connection string that works so I don't have to manually replace it every time I publish an update?
Thank you in advance for any information and advice!