From the Department of Grrrrrrrrr :rage:
So I'm minding my own business ... puttering around making no database-related changes and just being super-productive.
Hmmm ... I need to add that MummFuzzBrimProng field right now ...
Make the change to the model, save, compile, pop over into the Package Manager Console and run my usual ...
UDSto return the database to Stable state
AMPto recreate the Pending migration
UDto apply the changes
I get an exception!!!
ud Specify the '-Verbose' flag to view the SQL statements being applied to the target database. System.Collections.Generic.KeyNotFoundException: No ConnectionString named [DefaultConnection] exists! at III.Core.IIIConnectionStrings.FullName(String aConnectionName) in c:\Depot\III\Shared\Latest\Core\ConfigurationManager.cs:line 998 at ???.Data.ApplicationContext..ctor() in c:\Depot\???\???\Latest\Core\Data\Contexts\ApplicationContext.cs:line 36 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Data.Entity.Infrastructure.DbContextInfo.CreateInstance() at System.Data.Entity.Infrastructure.DbContextInfo..ctor(Type contextType, DbProviderInfo modelProviderInfo, AppConfig config, DbConnectionInfo connectionInfo, Func`1 resolver) at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext, DatabaseExistenceState existenceState, Boolean calledByCreateDatabase) at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration) at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator() at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run() at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner) at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force) at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0() at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) No ConnectionString named [DefaultConnection] exists!
The last line was the kicker!!!
No ConnectionString??? Huh?!?!?!?!
As Scooby-Doo would say ...
Ruh roh!!! :scream:
We've all said it plenty of times ... (wait for it) ...
I don't understand ... this was just working!!! WTF????
A look of panic, consternation, frustration, anger, denial, etc. ...
Makes you just want to second-guess career decisions made long ago, don't it? :wink:
Open a hole and pour down into it hours and hours you'll never get back...
There are days that I truly believe that this aphorism should be engraved on the inner eyelids of every aspiring software developer. Believe me ... I regret every time I forget this and have to déja vu it all over again! :smirk:
A smart developer - (a category in which I don't always qualify) - would have immediately just done what the first line of the error output recommended, namely,
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
But nooooo ... that's just too simple ... no way I do something like that!!!
Instead I immediately presumed that I had done something wrong - (a case of too much Occam's Razor perhaps!) - and tried rewinding my work of ... oh, I don't know ... the last three days!!! ... trying to figure out what I broke.
Teeth-gnashing, hair-pulling, general discomfort all around ...
Long story just slightly shorter, my .SUO1 file became corrupted, resulting in the StartUp Project setting becoming ... un-set. :flushed:
When I finally added the -verbose option and re-ran the UD command, I got the same error (of course!) but preceded with:
Using StartUp project 'Domain'. Using NuGet project 'Data'. ... ... ...
After scouring the solution layout for about the 40th time I blurted out to no one in particular ... Hey! How come Web isn't the start-up project anymore??? ... and things started clunking into place in my pea-sized mind! A quick right-mouse select later and I was back in business.
Hindsight being 20/20, I'd like to think that if instead of spending a couple hours running down various dead-end rabbit holes, I would had just immediately re-run the command with the verbose option ... I just immediately may have immediately noticed 'Domain' instead of the usual 'Web'. Immediately!
But if I had, I probably wouldn't have even bothered to take the time to bore y'all with my latest failings and deny you a friendly little chuckle at all my pain! :wink:
Happy coding ...
Solution User Options, from MSDN ↩