I had the same problem as using Entity Framework 6 code initially in a separate project from a published project under .net 4.5 using Visual Studio 2013 Update 4 and using a similar share method via the configSource connectionStrings attribute.
I list these details because it causes a bit of a perfect storm. Trying to get out of it, I came across several different errors and had to crack it in several ways, for the EF blog they should know that this is a mess and redistribute their approach . This is the best I could come up with (here are the dragons):
The publishing wizard does not understand configSource, so I removed this from conectionStrings in web.config, leaving an empty element (you can also delete it completely, but I felt that the existing but empty element with comment was preferable more). To make it work locally, I added a factory connection so that everything works in debug mode (locally) and makes the publishing wizard find the db migration. I used factory because connectionString always replaces factory, and I need to abuse it so that the project works before any conversions. Also make sure that the string you pass to the dbcontext aka constructor "connectionStringOrDatabaseName" is both the connection string AND the database name (makes the factory generated db match the db connection string).
Now it finds the database and it works locally, but in fact it does not use your sharedConfig (therefore, it will not always work when publishing). To address this, I then used the conversion of web.config to xsd: Replace / Insert a blank / missing connectionStrings element with one using configSource. If you try to publish now, you will encounter a problem when an invalid connectionStrings element is created.
Despite the fact that I was so close, I could not find / figure out a solution to this problem directly, so I had to use one more work: I created a custom transformation aka xsd: Import, which, if this configSource attribute replaces the parent element with the one what is in another file, I will leave the implementation as an exercise for the reader.
source share