I am trying the new Entity Framework Core with MySQL Connector.
I can get a valid DbContext
and write into the database so everything has been setup correctly.
I need to get the Connection
from the DbContext
because I have to test for it at application starting using a connection.Open()
inside a try
statement. If there is not a valid connection, the console app should try to start MySQL Server and retry.
How can I get the Connection
from the DbContext
?
Before EF6 by context.Connection
. After EF6 by context.Database.Connection
.
It seems the latest has been removed too from EFCore.
question from:
https://stackoverflow.com/questions/41935752/entity-framework-core-how-to-get-the-connection-from-the-dbcontext 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…