title: How do I create connection string programmatically to MS SQL in Entity Framework 6?
body: <p>How do I create connection string programmatically to MS SQL in Entity Framework 6?</p>
  
  <p>I'm using c# and WPF and I was wondering if someone could show me how or link me to a resource that shows how to set up connection strings programmatically in EF 6. The MSDN article explains that you can <a href="http://msdn.microsoft.com/en-us/data/jj680699#moving">http://msdn.microsoft.com/en-us/data/jj680699#moving</a> but it doesn't go into creating actual connection strings.</p>
  
  <p>So here is an EF6 example that works</p>
  
  <p>App.Config</p>
  
  <p>entityFramework codeConfigurationType="WPFwithEF.SqlConfiguration, WPFwithEF">
       /entityFramework</p>
  
  <p>context</p>
  
  <pre><code>public class ProductContext : DbContext
  {  
      public ProductContext():base("Wpf")
      { }
      public DbSet&lt;Category&gt; Categories { get; set; }
      public DbSet&lt;Product&gt; Products { get; set; }
  }
  </code></pre>
  
  <p>Configuration.cs</p>
  
  <pre><code>namespace WPFwithEF
  {
  public class SqlConfiguration : DbConfiguration
  {
  
      public SqlConfiguration()
      {
          SetProviderServices(SqlProviderServices.ProviderInvariantName,SqlProviderServices.Instance);           
          SetDefaultConnectionFactory(new SqlConnectionFactory());
      }
  }
  }
  </code></pre>
  
  <p>but if the context base is "name=Wpf" then this set up does not work is there a way to make that work? And i'm looking for the latest EF6 not the old way to do it.</p>