locked
EF Context connection string RRS feed

  • Question

  • I still have some confusion about EF Context taking a connection string as a parameter. It doesn't seem that this is a "connection string" in the SQL sense of the word. So I have two questions both of which will use the following as a talking point:

            public ContentEntities() : base("name=ContentEntities", "ContentEntities")
            {
                this.ContextOptions.LazyLoadingEnabled = true;
                OnContextCreated();
            }
        
            /// <summary>
            /// Initialize a new ContentEntities object.
            /// </summary>
            public ContentEntities(string connectionString) : base(connectionString, "ContentEntities")
            {
                this.ContextOptions.LazyLoadingEnabled = true;
                OnContextCreated();
            }
    


    with a configuration entry that looks like:

    The parameterless constructor does not apply to my questions. So my questions are:

    1. What is the second argument to the base constructor?

    2. If I just want to point to a new server I would add an entry to the configuration like:

     

        <add name="ContentProductionEntities" connectionString="metadata=res://*/Content.csdl|res://*/Content.ssdl|res://*/Content.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=production;initial catalog=Content;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

    and then the "connection string" becomes "name=ContentProductionEntities". Right?


    Kevin Burton

    Thursday, July 12, 2012 2:15 PM

Answers