title: How to get ConnectionString from EF7 DbContext
body: <h2>My Scenario:</h2>
  
  <p>I'm using EF7 for standard CRUD operations and Dapper for more complex queries that require increase in speed. From startup.cs I'm injecting my <code>DbContext</code> into my DAL which does then obviously does the database queries. Dapper requires a connection string. I want to inject my EF7 DbContext connection string into the Dapper query.</p>
  
  <h2>My Question:</h2>
  
  <p>How do I get the connection string from the DbContext like before: <code>DbContext.Database.Connection</code>?</p>
  
  <p>It changed from <code>Database</code> to <code>DatabaseFacade</code> type in EF7, and with that, <code>DbConnection Connection</code> was also removed.</p>
  
  <p>Surely there should be some persistent connection string in the <code>DbContext</code> that I can query?</p>
  
  <h2>My Research:</h2>
  
  <p>The method I'm using at the moment is, and it works:</p>
  
  <pre><code>public partial class CustomContext : DbContext
  {
      public readonly string _connectionString;
  
      public CustomContext (DbContextOptions options)
          : base(options)
      {
              _connectionString = ((SqlServerOptionsExtension)options.Extensions.First()).ConnectionString;
      }
  }
  </code></pre>
  
  <p><strong>I know its still in beta, but am I missing something?</strong></p>
  
  <p>Thanks for your time.</p>