Bug #72244 Connector/Net connection string formatting in app.config
Submitted: 4 Apr 2014 19:21 Modified: 27 Dec 2014 9:16
Reporter: Kevin Hollingshead Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.7.4.0 OS:Windows (Windows 8 under Parallels on Mac)
Assigned to: Assigned Account CPU Architecture:Any
Tags: app.config, EF, EF5, entity framework, formatting, Visual Studio, VS2013

[4 Apr 2014 19:21] Kevin Hollingshead
Description:
This probably rates only as an annoyance, but it is annoying and shouldn't be hard to fix. :)  I know I'm not using the latest and greatest, but my most recent attempt to upgrade EF and the MySQL Connector had me dead in the water for two days.  If this has been fixed in a later version please close this report with a note to that effect.

I'm using VS2013 with EF5.0.

Problem: After adding a data model, the connection string is added to the app.config file with incorrect formatting.  It is not indented, and the trailing </connectionStrings> tag is appended to the end of the newly added connection string instead of remaining on its own line.  Specifically (make sure you're looking at this without line wrapping):

  <connectionStrings>
  <add name="blah" connectionString="..." providerName="..." /></connectionStrings>

I would expect:

  <connectionStrings>
    <add name="blah" connectionString="..." providerName="..." />
  </connectionStrings>

How to repeat:
To reproduce (assumes existing VS2013 project):
1. Right click and delete the ADO.NET EF data model in the solution explorer if it's already added.
2. Open app.config and delete the associated connection string leaving the <connectionStrings> and </connectionStrings> tags.
3. Save all files.
4. Right click the project node in the solution explorer and select Add, New Item..., then select ADO.NET Entity Data Model (if not showing select "Visual C# Items" root in the list at the left of the Add New Item dialog).
5. Select Generate from database and Next.
6. Select the desired data connection, click the radio button for Yes, include sensitive data... and Next.
7. I get a warning here about using EF5. I just click Next.
8. Select Tables (I don't having any SP's or views), leave everything else as defaults, and click Finish.
9. I get two security warnings about the script and click OK for each.
10. I get a warning about app.config being modified outside of the source editor and select Yes to reload the modified file.
11. Find the new connection string and notice the misplacement of the </connectionStrings> tag.

Suggested fix:
I'm assuming the insert logic searches for the closing </connectionStrings> tag, then replaces that line with the new incorrect line.  

You need to indent the new connection string (level 2) and add a newline before the closing tag which should retain its orginal indentation (level 1).

*I'm not sure what facilities MS/VS provide for automated file editing.  If there's a way to get the user's indentation preferences (number of spaces/tabs) then use that, otherwise scan the file for other level 1 and level 2 items and save their whitespace prefixes to use for your formatting.  Or just use the default two-spaces-per-level.
[27 Nov 2014 9:16] Chiranjeevi Battula
Hello Kevin Hollingshead,

Thank you for the bug report.
I tried to reproduce the issue at my end using Visual Studio 2013 (C#.Net), MySQL Connector/Net 6.9.3,6.9.5 and EF6.0. 
but couldn't trace out misplacement of the </connectionStrings> tag. but it is changing from A to B.

A).
<connectionStrings>
<add name="blah" connectionString="..." providerName="..." />
</connectionStrings>

B).
<connectionStrings><add name="blah" connectionString="..." providerName="..." /></connectionStrings>

Could you please list out exact steps you tried out at your end, this would help us to reproduce the issue at our end.

Thanks,
Chiranjeevi.
[28 Dec 2014 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".