How to get connectionString from EF Core 2.0 DbContext
In EF6, this code works:
public string GetConnectionString(DbContext ctx)
{
ObjectContext _objectContext = ((IObjectContextAdapter)ctx).ObjectContext;
if (_objectContext?.Connection != null)
{
EntityConnection entityConnection = _objectContext.Connection as EntityConnection;
return entityConnection?.StoreConnection?.ConnectionString;
}
return null;
}
How do I do this in EF Core 2.0?
+3
source to share