Using EntityFramework, I have created an EntityDataModel (.edmx file) in App_Code\DAL. In the wizard, I named the entities 'DLGDBEntities'. I have a number of EntityDataSource
s in the .aspx where I've set the OnContextCreating
attribute to 'UseSurveyContext' which looks like this:
protected void UseSurveyContext(object sender, EntityDataSourceContextCreatingEventArgs e)
{
e.Context = surveyContext;
}
Setup code for the surveyContext is as follows:
DLGDBEntities surveyContext;
and in Page_Load:
surveyContext = new DLGDBEntities();
All of the above looks like the same code I've seen in every tutorial (eg: http://msdn.microsoft.com/en-us/library/cc668193.aspx#1), and I could swear I've had it working.
Now however, I am getting the error: Cannot implicitly convert type 'DAL.DLGDBEntities' to 'System.Data.Objects.ObjectContext'
What have I done wrong, and why did it work before?
((IObjectContextAdapter)context).ObjectContext
- hopefully it will help a bit. – Tonsure