none
How do I create an ObjectContext with EF6.0 and visual studio 2013 RRS feed

  • Question

  • Hi

    I am try to produce an ObjectContext with EF6 and VS 2013.  I appreciate that the recommended approach now is to use db context, however I happen to have a specific need for an Object Context at present.  With VS 2012 and EF %.0 I could create an object context by simply deleting the two .TT files  and selecting 'Default' from the code Generation Strategy in the properties of the model.

    This option is no longer available in vs 2013, but there is a tool available on the visual studio gallery (EF6.x EntityObject Generator for VB or C#) which would appear to provide the functionality I seek.  However each time I try to use this I do not seem to be presented with any options other than those for building a db context.

    I don't doubt that I doing something fundamentally incorrect but I'm at a loss as to what.  If any one has used this to produce an Object Context with ef 6 and vs 2013 I'd love to know what you did in order to achieve your desired result.

    If it transpires that there are different ways to approach this depending upon the language in which you are working then I would prefer to know the way that it should be done with vb.

    Many thanks to anyone who can assist me with this.

    Thanks

    Dom

    Wednesday, October 30, 2013 7:19 PM

Answers

  • Hello dms25,

    From your description, you want to know how to use ObjectContext in VS2013 and Entity Framework 6.

    This object is not recommended to use, however, if you persist to use it, my suggestion is that we could do a translation like below:

    static void Main(string[] args)
    
            {
    
                using (DataBaseDBEntities db = new DataBaseDBEntities())
    
                {
    
                    db.Database.Log = Console.Write;
    
                    ObjectContext objectContext = ((IObjectContextAdapter)db).ObjectContext;
    
                }
    
            }
    

    And using namespace as below:

    using System.Data.Entity.Core.Objects;
    
    using System.Data.Entity.Infrastructure;
    

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 31, 2013 1:57 AM
    Moderator