I had this below connection helper class in Visual Studio 2010
public class ConnectionHelper : IConnectionHelper
{
public ObjectContext Connection
{
get
{
if (_connection == null && HttpContext.Current.Items["DbActiveContext"] != null)
{
_connection = (ExampleWebsiteEntities)HttpContext.Current.Items["DbActiveContext"];
}
else
{
_connection = new ExampleWebsiteEntities(ConnectionString);
HttpContext.Current.Items["DbActiveContext"] = _connection;
}
return _connection;
}
}
private ObjectContext _connection;
public string ConnectionString
{
get
{
return ConfigurationManager.ConnectionStrings["ExampleWebsiteEntities"].ToString();
}
}
}
This above class works fine in Visual Studio 2010 but giving two errors in Visual Studio 2012
1- Cannot implicitly convert type 'Example.Datalayer.ExampleWebsiteEntities' to 'System.Data.Objects.ObjectContext'
on this line code
_connection = (ExampleWebsiteEntities)HttpContext.Current.Items["DbActiveContext"];
2- 'Example.Datalayer.ExampleWebsiteEntities' does not contain a constructor that takes 1 arguments
on this line code
_connection = new ExampleWebsiteEntities(ConnectionString);
I have double checked everything, but can't figure out what is the issue. Please help me in this. Thank you very much and Regards