是否可以使用C#在app.config和web.config中的<connectionStrings>
节点中编写?
我需要添加
<add name="Lorem" connectionString="metadata=res://*/Models.HOGC.csdl|res://*/Models.HOGC.ssdl|res://*/Models.HOGC.msl;provider=System.Data.SqlClient;provider connection string="data source=(local);initial catalog=Ipsum;user id=sa;password=Qwer0987;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
答案 0 :(得分:0)
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add("Lorem", "metadata=res://*/Models.HOGC.csdl|res://*/Models.HOGC.ssdl|res://*/Models.HOGC.msl;provider=System.Data.SqlClient;provider connection string="data source=(local);initial catalog=Ipsum;user id=sa;password=Qwer0987;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient");
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");