I m trying to migrate a project initially developed using EF4 to EF6, to take advantage of EF6 transactions management.

The problem I m facing is that the project has been created using the Database First approach, so when I m using code like `context.Database.UseTransaction`, I m encountering the following error:

```
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.

```

This exception triggers inside the `OnModelCreating` method of my `DbContext` class.

Any idea ?

Thanks

**EDIT:**

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.

In addition, here's the context class:

```
public class MyContext : BaseDbContext
{
    public MyContext (DbConnection existingConnection, bool contextOwnsConnection)
        : base(existingConnection, contextOwnsConnection)
    {
    }
}

```

And the connection string:

```
  <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" />

```

I tried setting the `providerName` to `System.Data.SqlClient` but it doesn't change anything.

Please note that the original connection string was in the database first format:

```
<add name="OrderManagement"
     connectionString="metadata=res://*/MyManagementModel.csdl|res://*/MyManagementModel.ssdl|res://*/MyManagementModel.msl;provider=System.Data.SqlClient;provider connection string=&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&quot;"
     providerName="System.Data.EntityClient" />

```

If I try to open a connection whilst I keep the connection string in the database first format, I m facing the exception `Keyword metadata not supported`, and when I put the connection string on the code first format, I m facing the error `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.`