locked
Where should we put the connection string? RRS feed

  • Question

  • I am upgrading to EF4.3.1, and it seems that it creates a new section called entityframework in web.config. Is this the new place that I should put my connection string, not the connection string sections which it used to be in?

      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True" />
          </parameters>
        </defaultConnectionFactory>
      </entityFramework>

    Wednesday, March 21, 2012 5:47 PM

Answers

  • Hi John;

    The location of the connection string within the App.Config or Web.Config has not changed in version 4.3.1. Please see this web page for details EF 4.3 Configuration File Settings. The defaultConnectionFactory found in the entityFramework node of the configuration file is used with code first when a connection string has not been defined, you can read more on that as well in the above link.

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by John Sun Thursday, March 22, 2012 5:40 PM
    Thursday, March 22, 2012 2:25 AM

All replies

  • On 3/21/2012 1:47 PM, John Sun wrote:
    > I am upgrading to EF4.3.1, and it seems that it creates a new section
    > called entityframework in web.config. Is this the new place that I
    > should put my connection string, not the connection string sections
    > which it used to be in?
    >
    >     <entityFramework>
    >         <defaultConnectionFactory  type="System.Data.Entity.Infrastructure.SqlConnectionFactory,  EntityFramework">
    >             <parameters>
    >                 <parameter  value="Data  Source=(localdb)\v11.0;  Integrated  Security=True;  MultipleActiveResultSets=True"  />
    >             </parameters>
    >         </defaultConnectionFactory>
    >     </entityFramework>
    >
     
    The connectionstring should be in the root web.config. There should a
    tag named <connectionstring> </connectionstring> where connectionstring
    information is kept.
     
    Wednesday, March 21, 2012 7:12 PM
  • Hi John;

    The location of the connection string within the App.Config or Web.Config has not changed in version 4.3.1. Please see this web page for details EF 4.3 Configuration File Settings. The defaultConnectionFactory found in the entityFramework node of the configuration file is used with code first when a connection string has not been defined, you can read more on that as well in the above link.

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by John Sun Thursday, March 22, 2012 5:40 PM
    Thursday, March 22, 2012 2:25 AM