Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8812433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:36:19+00:00 2026-06-14T03:36:19+00:00

Using EntityFramework, I have created an EntityDataModel (.edmx file) in App_Code\DAL. In the wizard,

  • 0

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 EntityDataSources 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:36:21+00:00Added an answer on June 14, 2026 at 3:36 am

    EntityDataSource control works only with ObjectContext. You can get your ObjectContext from your DbContext by using ((IObjectContextAdapter)context).ObjectContext.
    Note that in Visual Studio 2012 the default code generator was changed to generate POCO entities and DBContext as opposed to entities derived from EntityObject and ObjectContext which was the default in Visual Studio 2010.

    EDIT

    As pointed by Sven in the comments a new, EF6 compatible version of EntityDataSourceControl has been released and it takes the EF6 DbContext instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using EntityFramework, I have created a page with a number of DetailsView and FormView
I have created a new application using Entity Framework 4.3 database migrations. The migrations
I am using EntityFramework 4.1. I have the following model: public class User {
I'm using Entity Framework Code First v 4.3.0 I have a two entities with
I am using Entity Framework and DevExpress 10.5 XtraGrid. Imagine that we have entities
I have created a very simple Entity Framework 4.0 model using VS2010 Professional. Ignore
I have created an OData/WCF service using Visual Studio 2010 on Windows XP SP3
I'm using Entity Framework and I have created an interface for lease transactions: public
Using Code First Entity Framework with .NET MVC 4 I have created a new
Let me explain my problem: I have four tables created as objects using Entity

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.