title: The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development
body: <p>I m trying to migrate a project initially developed using EF4 to EF6, to take advantage of EF6 transactions management.</p>
  
  <p>The problem I m facing is that the project has been created using the Database First approach, so when I m using code like <code>context.Database.UseTransaction</code>, I m encountering the following error:</p>
  
  <pre><code>The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development.
  </code></pre>
  
  <p>This exception triggers inside the <code>OnModelCreating</code> method of my <code>DbContext</code> class.</p>
  
  <p>Any idea ?</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The thing is that it's legacy code using EDMX with database first approach. I have to implement EF6 transactions inside this project, so it should now be more like a code first pattern.</p>
  
  <p>In addition, here's the context class:</p>
  
  <pre><code>public class MyContext : BaseDbContext
  {
      public MyContext (DbConnection existingConnection, bool contextOwnsConnection)
          : base(existingConnection, contextOwnsConnection)
      {
      }
  }
  </code></pre>
  
  <p>And the connection string:</p>
  
  <pre><code>  &lt;add name="CS"
           connectionString="Data Source=MyServ;Initial Catalog=MyDBName;User Id=MyUser;Password=MyPwd;Pooling=True;Min Pool Size=5;Max Pool Size=20;Persist Security Info=True;MultipleActiveResultSets=True;Application Name=EntityFramework;Enlist=false"
           providerName="System.Data.EntityClient" /&gt;
  </code></pre>
  
  <p>I tried setting the <code>providerName</code> to <code>System.Data.SqlClient</code> but it doesn't change anything.</p>
  
  <p>Please note that the original connection string was in the database first format:</p>
  
  <pre><code>&lt;add name="OrderManagement"
       connectionString="metadata=res://*/MyManagementModel.csdl|res://*/MyManagementModel.ssdl|res://*/MyManagementModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;Data Source=MyServer;Initial Catalog=MyDBName;User Id=MyUser;Password=MyPwd;Pooling=True;Min Pool Size=5;Max Pool Size=20;Persist Security Info=True;MultipleActiveResultSets=True;Application Name=EntityFramework&amp;quot;"
       providerName="System.Data.EntityClient" /&gt;
  </code></pre>
  
  <p>If I try to open a connection whilst I keep the connection string in the database first format, I m facing the exception <code>Keyword metadata not supported</code>, and when I put the connection string on the code first format, I m facing the error <code>The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development.</code></p>