I am new to Entity-framework and MVC and I am trying to make a Data Access Layer (separate layer). I am using VS 2013, Entity-framework 6.1.3 and MVC5. So far I have created Connection Helper class to connect to the database, but I need a little help here.
IConnectionHelper.cs
public interface IConnectionHelper
{
string ConnectionString { get; }
ObjectContext Connection { get; }
}
ConnectionHelper.cs
public class ConnectionHelper : IConnectionHelper
{
public string ConnectionString
{
get {
return ConfigurationManager.ConnectionStrings["databaseEntities"].ToString();
}
}
private ObjectContext _connection;
public ObjectContext Connection
{
get {
//Need Help what to do here!
}
}
}
I just want to learn how to pass connection string name to its constructor. Can you guys please help me, Thanks