Connection-specific appsettings.json not updated in shadow folder when I switch connections
I am experiencing what appears to be a bug. I am LINQPad 7 and Peter Butzhammer's Entity Framework 6 driver. I am specifying a different appsettings.json in the connection properties of each of my connections. These settings files are used to determine the connection string on production servers, allowing me to reuse my configuration files of my various production sites in LINQPad, rather than having to specify connection string in each connection.
Usually, when I switch the connection through the drop-down menu in a query, everything works as expected: The appropriate appsettings.json is copied to the shadow folder, and the connection string is set appropriately. However, in some cases this does not happen. I noticed that I was sometimes getting unexpected results and eventually realized that the connection string was not being updated. I know that the connection change "registers", because the orange highlight changes when I switch from production to non-production databases. However, the connection string remains the same as the old connection and my queries are made against the old database (which is extremely dangerous when my scripts make updates to the database). I used Environment.CurrentDirectory.Dump()
to get the shadow folder and verified that the appsettings.json file was not being updated to the one associated with the newly selected connection. Strangely, Util.CurrentQuery.GetConnectionInfo().AppConfigPath.Dump()
points to the correct appsettings.json file for the new connection.
Changing the connection again usually fixes the problem, but not always.
I don't know if the problem is with LINQPad, or with the EF6 driver. Any ideas?
Comments
1 additional piece of info: I have confirmed that when I change my connection, LINQPad creates a new shadow folder in all cases. However, the appsetting.json in this new shadow folder is sometimes the one associated with the previous connection, rather than the one associated with the currently-selected location.
@JoeAlbahari Is it possible to get some feedback on whether this could be a bug with LINQPad?
I'll add some diagnostics to the next beta build (within the next week) to help with this.
Thank you Joe. Is this something you would like me to test with the beta and provide feedback? How would I get access to the diagnostic data?
Try the latest beta:
https://www.linqpad.net/linqpad7.aspx#beta
If it faults again, take a look in %localappdata%\LINQPad\logs.LINQPad7\log.txt and let me know if there's anything with a relevant timestamp.
Does this beta contain a fix, or just additional logging? It appears to have fixed the problem. I can still reproduce it reliably with v7.5.16, but I have not seen the problem so far with this beta version.
It does contain a potential fix, although it was a long shot without a repro. If it has fixed it, that's good news.
It appears that the fix did the trick. I will let you know if I encounter this problem again.
Thank you for the awesome support!