How should I edit an Entity Framework connection string?
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.
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.
The hack in the linked question works if it is used before the configuration system is used the first time. After that, it doesn’t work any more. The reason: There exists a class ClientConfigPaths that caches the paths. So, even after changing the path with SetData, it is not re-read, because there already exist cached … Read more
You can have separate configuration file, but you’ll have to read it “manually”, the ConfigurationManager.AppSettings[“key”] will read only the config of the running assembly. Assuming you’re using Visual Studio as your IDE, you can right click the desired project → Add → New item → Application Configuration File This will add App.config to the project … Read more
In Visual Studio 2008 I added the app.config file to the test project as an existing item and selected copy as link in order to make sure it’s not duplicated. That way I only have one copy in my solution. With several test projects it comes in really handy!
The basic <appSettings> is easier to deal with – just slap in a <add key=”….” value=”…” /> entry and you’re done. The downside is: there’s no type-checking, e.g. you cannot safely assume your number that you wanted to configure there really is a number – someone could put a string into that setting….. you just … Read more
The previous answer is correct but I’ll give you all the code as well. Your app.config should look like this: <?xml version=”1.0″ encoding=”utf-8″ ?> <configuration> <configSections> <section name=”ServicesSection” type=”RT.Core.Config.ServiceConfigurationSection, RT.Core”/> </configSections> <ServicesSection> <Services> <add Port=”6996″ ReportType=”File” /> <add Port=”7001″ ReportType=”Other” /> </Services> </ServicesSection> </configuration> Your ServiceConfig and ServiceCollection classes remain unchanged. You need a new … Read more
Try this AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
It is not trivial to create a .NET configuration file for a .DLL, and for good reason. The .NET configuration mechanism has a lot of features built into it to facilitate easy upgrading/updating of the app, and to protect installed apps from trampling each others configuration files. There is a big difference between how a … Read more
Yes, ConfigurationManager.AppSettings is available in .NET Core 2.0 after referencing NuGet package System.Configuration.ConfigurationManager. Credits goes to @JeroenMostert for giving me the solution.