Wednesday, 8 June 2011

SOLVED: Visual Studio inserts a text snippet instead of an EntityDataSource

I had finally gotten around to following the tutorials for an introduction to Entity Framework 4 and when got to the stage that required me to insert an EntityDataSource I hit a stumbling block: The EntityDataSource was being inserted as a long text snippet instead. Read on for a simple fix to this issue.

Problem

When looking at EntityDataSource (and some Dynamic Data controls as well) they have the following text snippet icon:

entityframework-error-1

When you double click on the icon to insert it into your document you are presented with some internal <soap-env> tags and a whole lot of other meta data:

entityframework-error-2

Searching for the problem didn't give me any immediate solutions. I did find this Microsoft Connect issue which had a suggested fix but it had ultimately been closed as non-reproducible:

After putting off looking into this seriously for about a month I finally gave up and reached out to the StackOverflow.com community.

Its well known phenomenon that when you ask a question out loud you can sometimes answer it yourself. In this case I solved the problem about 5 minutes after posting on SO.

Solution

The solution is very straightforward. I had initially tried to re-install Visual Studio 2010 SP1 thinking it might overwrite the error. No luck. I had followed the suggested solution in the Microsoft Connect issue in the link above with no success. I had also installed the latest out of band release of Entity Framework, the 4.1 standalone installer which brought the new code-first development model but nothing worked.

I was reluctant to re-install Visual Studio 2010 as it would take about an hour and a half of my time but it was starting to look like my only move.

Then I hit upon a simple solution - just reset the toolbox! To do this you simply have to:

  1. Right click on the toolbox window
  2. Choose Reset Toolbox
  3. Wait about 25 seconds while Visual Studio resets the toolbox

And you can now continue with your favourite Entity Framework tutorial!

kick it Shout it

No comments: