Quantcast
Channel: BrainStorage
Viewing all articles
Browse latest Browse all 102

Entity Framework Connection String Corruption?

$
0
0

I recently re-published an MVC 5 + EF 6 (code-first and database-first) application to my test site, and ran into the error:

“There is already an open datareader associated with this command which must be closed first.”

I did a little research and stumbled upon this post, which referred to the enabling of the MultipleActiveResultSets attribute in the connection string (as well as some general optimization techniques that I need to look at before going to Production).

The problem is that I knew this was already enabled. I did a little digging, and found a few curious things.

First, earlier on I had run into some problems with the database-first portion and ended up deleting that and starting over, which resulted in the creation of a new connection. I thought that I had successfully reproduced all of the settings for the new string, but somehow in web.config the attribute was listed as “multipleactiveresultsets=True”. This was despite the fact that right above it, the commented-out original version had the correct casing.

So I fixed that and then went to republish, but first reviewed the connection string settings in Web Publish (VS 2013 version). The string in the text box was correct, but when I opened the connection dialog and looked at the Advanced Settings, MultipleActiveResultSets was still shown as False in the dialog. So I don’t know what I would have gotten had I not checked those settings.

So it’s working now, but that was some strange behavior. Probably something I did wrong very late at night.


Filed under: .Net, Miscellaneous Tagged: Connection String, Entity Framework, MultipleActiveRecordSets, MVC 5

Viewing all articles
Browse latest Browse all 102

Trending Articles