none
DbContext in EDMX? RRS feed

  • Question

  • I've installed EF 4.1 from NuGet AND downloaded and ran the stand alone installer for EF 4.1, generated an EDMX, added the new dll as a reference, and still get a compile error (below)

    'Test.DAEntities' does not contain a definition for 'Entry' and no extension method 'Entry' accepting a first argument of type 'Test.DAEntities' could be found (are you missing a using directive or an assembly reference?)
    

    on this line of code:

    db.Entry(incident_to_update).State = EntityState.Modified;
    

    in the following (condense) block:

    Incident incident_to_update = db.Incidents.Single(c => c.IncidentId == obj_id);
    
    /*
    ...  modify object here, blah blah, blah
    */
    
    db.Entry(incident_to_update).State = EntityState.Modified;
    
    db.SaveChanges();
    
    EDMX does implement DbContext, right???  So what am I missing?

    Wednesday, January 18, 2012 9:52 PM

Answers

  • Hi CrazedPsychoRob;

    Have you also added the following using statement?

    using System.Data.Entity;

    To your question, "EDMX does implement DbContext, right???", ADO .Net Entity Data Model creates a ObjectContext by default to switch to DbContext look at the following post section 4, EF 4.1 Model & Database First Walkthrough.

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Wednesday, January 18, 2012 10:23 PM

All replies

  • Hi CrazedPsychoRob;

    Have you also added the following using statement?

    using System.Data.Entity;

    To your question, "EDMX does implement DbContext, right???", ADO .Net Entity Data Model creates a ObjectContext by default to switch to DbContext look at the following post section 4, EF 4.1 Model & Database First Walkthrough.

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Wednesday, January 18, 2012 10:23 PM
  • Thanks Fernando

     

    Ah, freaking-A!  The link that you posted did the trick...  Thanks!

    Wednesday, January 18, 2012 11:21 PM
  • Hi CrazedPsychoRob;

    Not a problem, always glad to help.

    Please return to the quesion and mark the post that answered the question by  click "Mark As Answer" on that post and "Mark as Helpful" if helpful.

    Have a great day.


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Thursday, January 19, 2012 3:39 PM