Categories c# entity-framework sql

How to get only the provider connection string from Web.Config in EF setup?

I am working on a project which is using Entity Framework. However, I need to execute some SQL queries (without the use of EF), and would like to retrieve the connection string from the Web.Config. Getting the full connection string is fine using:


Which returns the full connection string for the EF like this.

metadata=res://*/NameDB.csdl|res://*/NameDB.ssdl|res://*/NameDB.msl;provider=System.Data.SqlClient;provider connection string="Data Source=name-db;Initial Catalog=Name;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient

I require just the “provider connection string” section from this. Is there any clever way of doing this? Or do I just have to search the string for it using something like regex?

Any help/advice appreciated. Thanks.