Reputation: 9234
While developing locally, I have a connection string set with MultipleActiveResultSets set equal to TRUE. However, when I deploy my app and the sequelizer connectionString gets injected, MultipleActiveResultSets is left out. Is there anyway to enable MultipleActiveResultSets or otherwise update the connection string?
I am using Entity Framework 4.1 by the way.
Upvotes: 4
Views: 4831
Reputation: 19279
Update: Multiple Active Result Sets (MARS) can now be enabled for the injected connection string by using the Sequelizer admin panel. This is the recommended approach since the web.config
no longer needs to be modified, which causes an AppDomain
reload during startup
You can construct the connectionstring from the URI injected into your application web.config
. The process is described here, but I'm including the snippet below too:
var uriString = ConfigurationManager.AppSettings["SQLSERVER_URI"];
var uri = new Uri(uriString);
var connectionString = new SqlConnectionStringBuilder
{
DataSource = uri.Host,
InitialCatalog = uri.AbsolutePath.Trim('/'),
UserID = uri.UserInfo.Split(':').First(),
Password = uri.UserInfo.Split(':').Last(),
MultipleActiveResultSets = true,
}.ConnectionString;
Note the MultipleActiveResultSets = true
.
If you need to also build a non-Code-First connectionstring, you then need to use a EntityConnectionStringBuilder
for the rest, eg.:
var builder = new EntityConnectionStringBuilder();
builder.ProviderConnectionString = connectionString;
builder.Metadata = "somemetadata";
builder.Provider = "System.Data.SqlClient";
(also answered on the AppHarbor support forum)
Upvotes: 7