DB.Current issue #103

jotte opened this Issue Nov 3, 2011 · 1 comment


None yet

2 participants

jotte commented Nov 3, 2011

Massive is returning a convenience class DB.Current that is using an if clause (ConfigurationManager.ConnectionStrings.Count >1) use the first connection from your web.config.

The problem I found is that if you develop using Oracle and you have the client installed, then in the machine.config file you will/may have 2 entries (one named "LocalSqlServer" and one "OraAspNetConString") and in this case DB.Current should use the 3-th connection string and not the 2-nd as it is now in Massive.cs.

My quick fix was to replace this (lines #98 and #99)
if (ConfigurationManager.ConnectionStrings.Count > 1) {
return new DynamicModel(ConfigurationManager.ConnectionStrings[1].Name);
with following code:
var allConnections = ConfigurationManager.ConnectionStrings.Count;
if ( allConnections > 1)
for (int i = 1; i < allConnections; i++)
if (ConfigurationManager.ConnectionStrings[i].ProviderName == "System.Data.SqlClient")
return new DynamicModel(ConfigurationManager.ConnectionStrings[i].Name);
throw new InvalidOperationException("Can't find a valid 'System.Data.SqlClient' connection provider");

Thank you for your time!


Thanks for this :)

@robconery robconery closed this Nov 10, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment