I have just started playing with the ASP.NET MVC.
<add name="ApplicationServices" connectionString="Data Source=localhost;Port=3306;Database=test;User id=root;Password=admin;" providerName="MySql.Data.MySqlClient" /> <add name="testEntities" connectionString="metadata=res://*/Models.testDB.csdl|res://*/Models.testDB.ssdl|res://*/Models.testDB.msl;provider=MySql.Data.MySqlClient;provider connection string="server=localhost;port=3306;database=test;User Id=root;password=admin"" providerName="System.Data.EntityClient" />
VS automatically creates connection strings on web.config with the DB details when you add a ADO entity data model. The problem is that I use ASP.NET user/privileges schema which uses "ApplicationServices" connection string which exists by default. All of those tables as well as my application tables exists on the same DB. I want the DB details(host/user/pass) to come from a single connection string entry. Or even if there are multiple connection string entries is it possible to get the DB details alone from a single source.
I come from the PHP world and couldn't figure out how to get it done from the other similar threads that I had bumped into.
Use simple approach. Define only ApplicationServices in the configuration and build EF connection string in the application.
ObjectContext offers constructors with
EntityConnection or a connection string directly. Pass ApplicationService's connection string to the provider connection string part in EF connection string.
EF offers defining connection string in configuration part but in 90% situations the only part which will change is provider connection string. Information about csdl, ssdl and msl files will usually not change. The only reason to change those resources can be supporting multiple database providers and in such case provider connection string part will change as well. In my opinion many applications can have those resource paths hardcoded directly in related context.