Showing posts with label the given key was not present in the dictionary. Show all posts
Showing posts with label the given key was not present in the dictionary. Show all posts

How to solve "The given key was not present in the dictionary" problem!

Recently I came across this weird problem at my workplace when I was working with entity framework and .net 4.0. 
I was working on a proof of concept using the entity framework and SQL server express. That seemed easy and straight forward and I jumped right into coding it. Unfortunately I failed in the very first step, I just couldn't connect the database. It threw the error, "the given key was not present in the dictionary".
Naturally I googled and most of the solutions pointed to me to delete the folder
C:\users\yourusername\appdata\local\Microsoft\visualstudio\10.0\
But in vain , it didn't work. Then I googled more . I found that , there existed another directory where some more configurations are stored


Solution 1:
Navigate to the below folder

C:\users\yourusername\appdata\roaming\Microsoft\visualstudio\10.0\serverexplorer\

You will find a file named defaultview.seview

Delete this file. This is where all the data connections are stored for your visual studio installation.please remember that this will delete all the data connections.

"This problem usually comes up when we have used a third party database connector/provider
And later uninstalled it without deleting the data connection in visual studio. "


Solution 2:
Another alternative solution is installing the data provider driver in case you have uninstalled it but forgot to delete the data connection for that provider. In my case it was MySQL .

I had installed the MySQL connector for .net and worked on the entity framework when I was done I uninstalled the driver without deleting the data connection in visual studio. When I later installed the driver again the problem was rectified!

If any of the above solutions worked please let me know which solution worked out for you through comments. Hope this helped. If you have found an alternate solution please add it in the comments section.