I recently had to edit my app.config file to change the connection string for an Entity Framework data model (.edmx
file). But I'd like to know: Is there a way to edit the EF connection string using the designer?
The original connection string is auto-generated by the Entity Data Model wizard. The connection string then cannot be changed - it remains disabled in the properties window of the .edmx designer. I like to avoid editing XML by hand if I can (in app.config), so I was wondering if there is a way to get back into the original wizard screen to make connection string changes and let the tool edit the app.config file for me.
If you save your connection string in the udl file, the user can change the connection via an interface by simply double clicking that file. You can set your connection string in the app to point to the udl file. You can also launch the udl interface programmatically if you want.
You need to use the connectionStrings tag to specify the connection string in the web. config file as in the following image. Write this XML markup in the web config file for declaration of the connection. You can add many tags for each database connection.
If you remove the connection string from the app.config
file, re-running the entity Data Model wizard will guide you to build a new connection.
No, you can't edit the connection string in the designer. The connection string is not part of the EDMX file it is just referenced value from the configuration file and probably because of that it is just readonly in the properties window.
Modifying configuration file is common task because you sometimes wants to make change without rebuilding the application. That is the reason why configuration files exist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With