We use Entity Framework 5, but have a requirement to ALSO use a normal database connection from the application for some custom SQL we need to perform.
So, I am creating a DatabaseAccess class which handles this connection. Is there a way that I can populate the connection string, by checking the Entity Framework connection string?
SqlConnection cnn; connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
Can I build that from checking Entity Framework?
Do you mean, can you use a SqlConnection with your EF DbContext?
The DbContext class has a constructor where you can pass in a SqlConnection, and then tell EF whether or not it owns it.
var YourContext = new YourContext(SqlConnection, true);
You can get the connectionstring used by EF by using the following:
Or as mark says you can initalise the context with a sqlconnection