There should be three constructors for the ObjectContext class
public Entities() :
base("name=Entities", "Entities")
{
this.OnContextCreated();
}
public Entities(string connectionString) :
base(connectionString, "Entities")
{
this.OnContextCreated();
}
public Entities(global::System.Data.EntityClient.EntityConnection connection) :
base(connection, "Entities")
{
this.OnContextCreated();
}
Pass in the connection string or create an EntityConnection object
private static EntityConnection GetConnection()
{
EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
entityBuilder.ProviderConnectionString = ConfigurationManager.ConnectionStrings["xxx"].ConnectionString;
entityBuilder.Provider = "System.Data.SqlClient";
entityBuilder.Metadata = @"res://*/xxx.csdl|res://*/xxx.ssdl|res://*/xxx.msl";
return new EntityConnection(entityBuilder.ToString());
}