views:

71

answers:

0

I'd like to store the Entity model connection string in the app.config using the same approach used by old Typed DataSet. Both use the same section: <connectionStrings>.

Entity saves the connection as:

<add name="MyDB_Entities" connectionString="metadata=res://*/MyDB.csdl|res:......" providerName="System.Data.EntityClient" />

Typed DataSet saves as:

<add name="MyTest.Properties.Settings.MyDbString" connectionString="Data Source=.\sqlexpress;...." providerName="System.Data.SqlClient" />

The former is only accessibile using a "not-typed" syntax, like:

string s = ConfigurationManager.ConnectionStrings["MyDB_Entities"].ConnectionString;

The latter is "wrapped" by Settings.settings. So you can write:

string s = Settings.Default.MyDbString;

The Entity entry does not contain the namespace so Settings.settings is not able to parse it. Any idea /suggestion?

related questions