Bug #91807 DbContext can now be created with a DbConnection that is already opened not work
Submitted: 26 Jul 2018 16:07 Modified: 31 Jul 2018 7:17
Reporter: Roberto Parise Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:8.0.11.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: Connection, entityframework

[26 Jul 2018 16:07] Roberto Parise
Description:
I try to follow documentation on page 

https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html

where says:
"DbContext can now be created with a DbConnection that is already opened, which enables scenarios where it would be helpful if the connection could be open when creating the context (such as sharing a connection between components when you cannot guarantee the state of the connection)"

but i can't connect my EF with this connection.
All the time code try to create model (invoke OnModelCreating) and fire error.

i try this problem with version 8.0.11, 6.10.7 and 6.9.12 with no success.

There is a way to enable this interesting feature?

How to repeat:
Follow the example:

[DbConfigurationType(typeof(MySqlEFConfiguration))]
  class JourneyContext : DbContext
  {
    public DbSet<MyPlace> MyPlaces { get; set; }

    public JourneyContext()
      : base()
    {

    }

    public JourneyContext(DbConnection existingConnection, bool contextOwnsConnection)
      : base(existingConnection, contextOwnsConnection)
    {

    }
  }

  using (MySqlConnection conn = new MySqlConnection("<connectionString>"))
  {
    conn.Open();
    ...

    using (var context = new JourneyContext(conn, false))
    {
      ...
    }
  }
[31 Jul 2018 7:17] Chiranjeevi Battula
Hello Roberto Parise,

Thank you for the bug report.
I could not repeat the issue at our end using with Visual Studio 2017 and Connector/NET 8.0.12 version.
If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

Thanks,
Chiranjeevi.