title: changing database in entity framework c#.net
body: <p>Let us consider the entity class listed as</p>
  
  <pre><code>public NerdDinnerEntities() : base("name=NerdDinnerEntities", "NerdDinnerEntities")
          {
  
              this.ContextOptions.LazyLoadingEnabled = true;
  
              OnContextCreated();
          }
  
          /// &lt;summary&gt;
          /// Initialize a new NerdDinnerEntities object.
          /// &lt;/summary&gt;
          public NerdDinnerEntities(string connectionString) : base(connectionString, "NerdDinnerEntities")
          {
              this.ContextOptions.LazyLoadingEnabled = true;
  
              OnContextCreated();
          }
  
  
  
          /// &lt;summary&gt;
          /// Initialize a new NerdDinnerEntities object.
          /// &lt;/summary&gt;
          public NerdDinnerEntities(EntityConnection connection) : base(connection, "NerdDinnerEntities")
          {
              this.ContextOptions.LazyLoadingEnabled = true;
              OnContextCreated();
          }  
  </code></pre>
  
  <p>and these being read as  in web config file as  </p>
  
  <pre><code>&lt;add name="NerdDinnerEntities" 
      connectionString="metadata=res://*/Models.NerdDinner.csdl|res://*/Models.NerdDinner.ssdl|res://*/Models.NerdDinner.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;Data Source=*;
      Initial Catalog=db;User ID=*;Password=****;
      MultipleActiveResultSets=True&amp;quot;" providerName="System.Data.EntityClient" /&gt;
  </code></pre>
  
  <p>and my problem is i need to change the database name from db to db1 through code with out change in web config file..</p>
  
  <p>as enitity as a class name called changedatabase() .. but i do not know how to use it...</p>
  
  <p>and my another question is it possible to add a new dll in to this project and change the connectionstring meta data there by when ever the connection is opened there by it will come to that dll and change the database name only and return with that database...</p>
  
  <p>Waiting for your valuable commands and sugessions</p>