locked
EF 4.1 RRS feed

  • Question

  • where is ContextBuilder that was in Microsoft.Data.Entity.CTP here in EF 4.1?
    Sunday, July 31, 2011 7:51 AM

Answers

All replies

  • Hi,

    The ContextBuilder has been splitted into two seperate classes for a long time ago (in CTP4), you can read about it in this thread:

    http://social.msdn.microsoft.com/Forums/en/adonetefx/thread/5f59aad6-8a0b-4e57-9325-d399493ceadf

    also this blog article has a description of this

    http://blogs.msdn.com/b/adonet/archive/2010/07/14/ctp4codefirstwalkthrough.aspx

    Hope this helps!


    --Rune

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Sunday, July 31, 2011 8:00 AM
  • Hi Rune, thank you for the answer.

    I read it, and before you introduce it to me but I couldn't replace my old code:

    public class Repository<TContext> where TContext : ObjectContext

    {

                    [ThreadStatic]

                    private static TContext context;

                    public static TContext Context

                    {

                    get

                    {

                     if (context == null)

    {

    var ctxBuilder = new ContextBuilder<TContext>();

    var cs = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString.SQL Server (SqlClient)"];

    context = ctxBuilder.

    Create(new SqlConnection(cs));

                    }

                    return context;

    }

    }

    }

    Sunday, July 31, 2011 8:58 AM
  • Hi,

    Well, the blog article describes your problem quite good in section 6 Create a derivied context. That describes how you use a model builder to create the model object which you can in turn use to create the object context by calling CreateObjectContext.

    I can't see why this shouldn't work for you.


    --Rune

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Sunday, July 31, 2011 2:11 PM